arnaucube
arnaucube/goBlockchainDataAnalysisPublic Self-hosted repository
small update: integrated webserver in the main.go, small frontend changes, not finished relation loops bug fix
arnaucode idoctnef@openmailbox.org
Thu, 17 Aug 2017 13:51:02 +0200
commit

88fb44d9657cba3f3a4ff220af773303bd582800

parent

ff774543e827888b89feedbe09ea3f39c172d296

M README.md → README.md

@@ -7,10 +7,14 @@ - Network Address generation avoiding infinite relation loops

- 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 @@ 3.1. The next runs, once the database have data, can just run:

``` ./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 @@ ### Some screenshots

![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")
M addressTree.go → addressTree.go

@@ -2,11 +2,12 @@ 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 @@ nodes := []NodeModel{}

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 {
M main.go → main.go

@@ -67,6 +67,8 @@ }

log.Printf("Block count: %d", blockCount) } } + //run thw webserver + go webserver() //http server start readServerConfig("./serverConfig.json")

@@ -82,3 +84,9 @@ log.Fatal(http.ListenAndServe(":"+serverConfig.ServerPort, handlers.CORS(originsOk, headersOk, methodsOk)(router)))

//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) +}
M mongoOperations.go → mongoOperations.go

@@ -12,7 +12,7 @@ )

//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 @@ json.Unmarshal([]byte(content), &mongoConfig)

} func getSession() (*mgo.Session, error) { - session, err := mgo.Dial("mongodb://" + mongoConfig.Ip) + session, err := mgo.Dial("mongodb://" + mongoConfig.IP) if err != nil { panic(err) }
M serverConfig.go → serverConfig.go

@@ -20,10 +20,11 @@ }

//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
M web/css/style.css → 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; +}
M web/views/addressNetwork/addressNetwork.html → web/views/addressNetwork/addressNetwork.html

@@ -1,7 +1,7 @@

<div class="row"> <div class="col-sm-3"> <div class="panel-heading c_blueGrey300"> - <h3 class="panel-title">All addresses</h3> + <h3 class="panel-title">All addresses ({{addresses.length}})</h3> </div> <div class="panel-body" style="max-height: 500px;overflow-y: scroll;"> <div class="form-group label-floating">

@@ -18,7 +18,7 @@ </div>

</div> <div class="col-sm-9"> <div class="panel-heading c_blueGrey300"> - <h3 class="panel-title">Address history Network Map</h3> + <h3 class="panel-title">Address history Network Map {{selectedAddress.id}}, BlockHeight: {{selectedAddress.group}}</h3> </div> <div class="panel-body"> <div id="mynetwork" style="height:800px;"></div>
M web/views/addressNetwork/addressNetwork.js → web/views/addressNetwork/addressNetwork.js

@@ -71,8 +71,10 @@ }, function(data, status, headers, config) {

console.log('data error'); }); + $scope.selectedAddress=""; $scope.getAddressNetwork = function(address) { console.log(address); + $scope.selectedAddress=address; $http.get(urlapi + 'address/network/' + address.id) .then(function(data, status, headers, config) { console.log('data success');
M web/views/sidebar.html → web/views/sidebar.html

@@ -2,32 +2,32 @@ <div class="c_grey600" style="height:800px;margin-top:-20px;">

<ul class="nav o_sidebar"> <li> <a href="#!/main"> - <i class="fa fa-home" aria-hidden="true"></i> Main + <i class="fa fa-home o_sidebarIcon" aria-hidden="true"></i> Main </a> </li> <li> <a href="#!/network"> - <i class="fa fa-chain" aria-hidden="true"></i> Network + <i class="fa fa-chain o_sidebarIcon" aria-hidden="true"></i> Network </a> </li> <li> <a href="#!/addressNetwork"> - <i class="fa fa-sitemap" aria-hidden="true"></i> Address Network + <i class="fa fa-sitemap o_sidebarIcon" aria-hidden="true"></i> Address Network </a> </li> <li> <a href="#!/sankey"> - <i class="fa fa-code-fork" aria-hidden="true"></i> Sankey diagram + <i class="fa fa-code-fork o_sidebarIcon" aria-hidden="true"></i> Sankey diagram </a> </li> <li> <a href="#!/dateAnalysis"> - <i class="fa fa-bar-chart" aria-hidden="true"></i> Date Analysis + <i class="fa fa-bar-chart o_sidebarIcon" aria-hidden="true"></i> Date Analysis </a> </li> <li> <a href="javascript:void(0)"> - <i class="fa fa-area-chart" aria-hidden="true"></i> Timeline + <i class="fa fa-area-chart o_sidebarIcon" aria-hidden="true"></i> Timeline </a> </li> </ul>