diff --git a/README.md b/README.md index 53110b6..544a353 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # goBlockchainDataAnalysis blockchain data analysis, written in Go +#### Not finished - ToDo list +- Backend + - 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 + ### Install 1. Nodejs & NPM https://nodejs.org/ --> to serve the web, not necessary if the web files are in a webserver @@ -74,6 +81,9 @@ Webapp will run on 127.0.0.1:8080 ### 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/goBlockchainDataAnalysis05.png "goBlockchainDataAnalysis") diff --git a/addressTree.go b/addressTree.go index 9b83a43..885dffe 100644 --- a/addressTree.go +++ b/addressTree.go @@ -6,6 +6,8 @@ import ( "gopkg.in/mgo.v2/bson" ) +var upLevelEdge EdgeModel + func upTree(address string, network NetworkModel) NetworkModel { var upNetwork NetworkModel @@ -31,9 +33,16 @@ func upTree(address string, network NetworkModel) NetworkModel { err := nodeCollection.Find(bson.M{"id": }).All(&edges) check(err) */ + edgeUpCheck := EdgeModel{} + err := edgeCollection.Find(bson.M{"to": e.From}).One(&edgeUpCheck) + check(err) + //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 { + //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 upNetwork = upTree(e.From, network) for _, upN := range upNetwork.Nodes { if nodeInNodes(network.Nodes, upN) == false { diff --git a/exploreBlockchain.go b/exploreBlockchain.go index 9f189c4..69873db 100644 --- a/exploreBlockchain.go +++ b/exploreBlockchain.go @@ -26,7 +26,7 @@ func explore(client *btcrpcclient.Client, blockHash string) { block, err := client.GetBlockVerbose(bh) check(err) - if block.Height > 0 { + if block.Height > config.StartFromBlock { for k, txHash := range block.Tx { if k > 0 { realBlocks++ diff --git a/goBlockchainDataAnalysis00.png b/goBlockchainDataAnalysis00.png new file mode 100644 index 0000000..ab7153a Binary files /dev/null and b/goBlockchainDataAnalysis00.png differ diff --git a/goBlockchainDataAnalysis06.gif b/goBlockchainDataAnalysis06.gif new file mode 100644 index 0000000..a5dcef6 Binary files /dev/null and b/goBlockchainDataAnalysis06.gif differ diff --git a/mongoOperations.go b/mongoOperations.go index ce27324..58978ed 100644 --- a/mongoOperations.go +++ b/mongoOperations.go @@ -120,7 +120,7 @@ func nodeInNodes(nodes []NodeModel, node NodeModel) bool { } func edgeInEdges(edges []EdgeModel, edge EdgeModel) bool { for _, e := range edges { - if e.From == edge.From && e.To == edge.To { + if e.From == edge.From && e.To == edge.To && e.Label == edge.Label && e.BlockHeight == edge.BlockHeight { return true } } diff --git a/readConfig.go b/readConfig.go index 938714b..f55021c 100644 --- a/readConfig.go +++ b/readConfig.go @@ -6,12 +6,13 @@ import ( ) type Config struct { - User string `json:"user"` - Pass string `json:"pass"` - Host string `json:"host"` - Port string `json:"port"` - GenesisTx string `json:"genesisTx"` - GenesisBlock string `json:"genesisBlock"` + User string `json:"user"` + Pass string `json:"pass"` + Host string `json:"host"` + Port string `json:"port"` + GenesisTx string `json:"genesisTx"` + GenesisBlock string `json:"genesisBlock"` + StartFromBlock int64 `json:"startFromBlock"` } var config Config diff --git a/serverRoutes.go b/serverRoutes.go index 51264a8..34a0dbe 100644 --- a/serverRoutes.go +++ b/serverRoutes.go @@ -90,7 +90,7 @@ func AllAddresses(w http.ResponseWriter, r *http.Request) { ipFilter(w, r) nodes := []NodeModel{} - iter := nodeCollection.Find(bson.M{}).Limit(10000).Iter() + iter := nodeCollection.Find(bson.M{"type": "address"}).Limit(10000).Iter() err := iter.All(&nodes) //convert []resp struct to json diff --git a/web/views/main/main.html b/web/views/main/main.html index 2b06005..72d2aaf 100644 --- a/web/views/main/main.html +++ b/web/views/main/main.html @@ -2,7 +2,7 @@
BlockHeight | @@ -63,8 +63,8 @@||||
---|---|---|---|---|
{{tx.blockheight}} | - - +{{tx.from}} | +{{tx.to}} | {{tx.label}} | View |