diff --git a/README.md b/README.md index 544a353..665d217 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,14 @@ blockchain data analysis, written in Go - Sankey Address generation without loops - Frontend - After Sankey visualization, go to Network Address visualization and render without Sankey dots - +- Both + - Tx/day + - Tx volume + - Block size + - Blockchain size ### Install -1. Nodejs & NPM https://nodejs.org/ --> to serve the web, not necessary if the web files are in a webserver +1. Nodejs & NPM https://nodejs.org/ --> to get npm packages for the web 2. MongoDB https://www.mongodb.com/ 3. Faircoin wallet https://download.faircoin.world/, or the Cryptocurrency desired wallet 4. goBlockchainDataAnalysis https://github.com/arnaucode/goBlockchainDataAnalysis @@ -61,8 +65,11 @@ Wait until the entire blockchain is downloaded. ``` ./goBlockchainDataAnalysis ``` +Webapp will run on 127.0.0.1:8080 -4. Run the webserver, in the /web directory +4. ADDITIONAL - Run the webserver, directly from the /web directory +This can be useful if need to deploy the API server in one machine and the webserver in other. +In the /web directory: ``` npm start ``` @@ -83,7 +90,7 @@ Webapp will run on 127.0.0.1:8080 ![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/goBlockchainDataAnalysis00.png "goBlockchainDataAnalysis") -![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/goBlockchainDataAnalysis06.png "goBlockchainDataAnalysis") +![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/goBlockchainDataAnalysis06.gif "goBlockchainDataAnalysis") ![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/goBlockchainDataAnalysis05.png "goBlockchainDataAnalysis") diff --git a/addressTree.go b/addressTree.go index 885dffe..a3b454f 100644 --- a/addressTree.go +++ b/addressTree.go @@ -2,12 +2,13 @@ package main import ( "fmt" + "log" + + "github.com/fatih/color" "gopkg.in/mgo.v2/bson" ) -var upLevelEdge EdgeModel - func upTree(address string, network NetworkModel) NetworkModel { var upNetwork NetworkModel @@ -33,16 +34,22 @@ func upTree(address string, network NetworkModel) NetworkModel { err := nodeCollection.Find(bson.M{"id": }).All(&edges) check(err) */ + endBranch := false edgeUpCheck := EdgeModel{} err := edgeCollection.Find(bson.M{"to": e.From}).One(&edgeUpCheck) - check(err) + if err != nil { + log.Println(err) + color.Blue("not found") + endBranch = true + } //need to be fixed when there is a bucle between the addresses (A-->B, B-->C, C-->A) fmt.Println(e.From + " - " + e.To) //if e.From != e.To && e.From != upLevelEdge.To && e.To != upLevelEdge.From { //if e.From != e.To { - if edgeInEdges(network.Edges, edgeUpCheck) == false { - upLevelEdge = e + fmt.Println(endBranch) + fmt.Println(edgeInEdges(network.Edges, edgeUpCheck)) + if edgeInEdges(network.Edges, edgeUpCheck) == false && endBranch == false { upNetwork = upTree(e.From, network) for _, upN := range upNetwork.Nodes { if nodeInNodes(network.Nodes, upN) == false { diff --git a/goBlockchainDataAnalysis b/goBlockchainDataAnalysis new file mode 100755 index 0000000..2921e3c Binary files /dev/null and b/goBlockchainDataAnalysis differ diff --git a/main.go b/main.go index e36d2d3..944f1fd 100644 --- a/main.go +++ b/main.go @@ -67,6 +67,8 @@ func main() { log.Printf("Block count: %d", blockCount) } } + //run thw webserver + go webserver() //http server start readServerConfig("./serverConfig.json") @@ -82,3 +84,9 @@ func main() { //log.Fatal(http.ListenAndServe(":"+serverConfig.ServerPort, router)) } + +func webserver() { + log.Println("webserver in port " + serverConfig.WebServerPort) + http.Handle("/", http.FileServer(http.Dir("./web"))) + http.ListenAndServe(":"+serverConfig.WebServerPort, nil) +} diff --git a/mongoOperations.go b/mongoOperations.go index 58978ed..86796e4 100644 --- a/mongoOperations.go +++ b/mongoOperations.go @@ -12,7 +12,7 @@ import ( //MongoConfig stores the configuration of mongodb to connect type MongoConfig struct { - Ip string `json:"ip"` + IP string `json:"ip"` Database string `json:"database"` } @@ -28,7 +28,7 @@ func readMongodbConfig(path string) { } func getSession() (*mgo.Session, error) { - session, err := mgo.Dial("mongodb://" + mongoConfig.Ip) + session, err := mgo.Dial("mongodb://" + mongoConfig.IP) if err != nil { panic(err) } diff --git a/serverConfig.go b/serverConfig.go index 3411e09..490f597 100644 --- a/serverConfig.go +++ b/serverConfig.go @@ -20,10 +20,11 @@ type Route struct { //server config type ServerConfig struct { - ServerIP string `json:"serverIP"` - ServerPort string `json:"serverPort"` - AllowedIPs []string `json:"allowedIPs"` - BlockedIPs []string `json:"blockedIPs"` + ServerIP string `json:"serverIP"` + ServerPort string `json:"serverPort"` + WebServerPort string `json:"webserverPort"` + AllowedIPs []string `json:"allowedIPs"` + BlockedIPs []string `json:"blockedIPs"` } var serverConfig ServerConfig diff --git a/web/css/style.css b/web/css/style.css index 4bdfd4f..5433452 100644 --- a/web/css/style.css +++ b/web/css/style.css @@ -32,8 +32,13 @@ /* sidebar */ .o_sidebar a{ color: white; + padding: 10px; } .o_sidebar a:hover{ background: #9E9E9E!important; color: white; } +.o_sidebarIcon{ + font-size: 180%; + margin-right: 10px; +} \ No newline at end of file diff --git a/web/views/addressNetwork/addressNetwork.html b/web/views/addressNetwork/addressNetwork.html index b63b0c5..3278d0d 100644 --- a/web/views/addressNetwork/addressNetwork.html +++ b/web/views/addressNetwork/addressNetwork.html @@ -1,7 +1,7 @@