Browse Source

fixed address tree concurrent generation algorithm

master
arnaucode 6 years ago
parent
commit
ff774543e8
12 changed files with 40 additions and 20 deletions
  1. +10
    -0
      README.md
  2. +10
    -1
      addressTree.go
  3. +1
    -1
      exploreBlockchain.go
  4. BIN
      goBlockchainDataAnalysis00.png
  5. BIN
      goBlockchainDataAnalysis06.gif
  6. +1
    -1
      mongoOperations.go
  7. +7
    -6
      readConfig.go
  8. +1
    -1
      serverRoutes.go
  9. +6
    -6
      web/views/main/main.html
  10. +2
    -2
      web/views/navbar.html
  11. +1
    -1
      web/views/sankey/sankey.html
  12. +1
    -1
      web/views/sankey/sankey.js

+ 10
- 0
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")

+ 10
- 1
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 {

+ 1
- 1
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++

BIN
goBlockchainDataAnalysis00.png

Before After
Width: 1280  |  Height: 858  |  Size: 145 KiB

BIN
goBlockchainDataAnalysis06.gif

Before After
Width: 600  |  Height: 338  |  Size: 2.5 MiB

+ 1
- 1
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
}
}

+ 7
- 6
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

+ 1
- 1
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

+ 6
- 6
web/views/main/main.html

@ -2,7 +2,7 @@
<div class="col-sm-4">
<div class="panel">
<div class="panel-heading c_blueGrey300">
<h3 class="panel-title">Last addresses</h3>
<h3 class="panel-title">Last addresses used</h3>
</div>
<div class="panel-body" style="max-height: 300px;overflow-y: scroll;">
<div class="list-group-item" ng-repeat="node in addresses">
@ -26,7 +26,7 @@
<div class="col-sm-4">
<div class="panel">
<div class="panel-heading c_blueGrey300">
<h3 class="panel-title">Other</h3>
<h3 class="panel-title">Hours</h3>
</div>
<div class="panel-body">
<canvas id="doughnut" class="chart chart-doughnut" chart-data="data" chart-labels="labels">
@ -43,14 +43,14 @@
</div>
<div class="panel-body" style="max-height: 350px;overflow-y: scroll;">
<table class="table table-striped table-hover">
<colgroup>
<!--<colgroup>
<col class="col-md-2">
<col class="col-md-2">
<col class="col-md-2">
<col class="col-md-2">
<col class="col-md-2">
<col class="col-md-2">
</colgroup>
</colgroup>-->
<thead>
<tr>
<th>BlockHeight</th>
@ -63,8 +63,8 @@
<tbody>
<tr ng-repeat="tx in txs">
<td>{{tx.blockheight}}</td>
<td style="max-width:100px;overflow-x:hidden;">{{tx.from}}</td>
<td style="max-width:100px;overflow-x:hidden;">{{tx.to}}</td>
<td>{{tx.from}}</td>
<td>{{tx.to}}</td>
<td>{{tx.label}}</td>
<td><a ng-href="#!/tx/{{tx.id}}">View</a></td>
</tr>

+ 2
- 2
web/views/navbar.html

@ -10,13 +10,13 @@
<a class="navbar-brand" href="/">goBlockchainDataAnalysis</a>
</div>
<div class="navbar-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<!--<ul class="nav navbar-nav">
<li><a href="#!/network">Network</a></li>
<li><a href="#!/addressNetwork">Address Network</a></li>
<li><a href="#!/sankey">Sankey diagram</a></li>
<li><a href="#!/dateAnalysis">Date Analysis</a></li>
<li><a href="javascript:void(0)">Timeline</a></li>
</ul>
</ul>-->
<form class="navbar-form navbar-left">
<div class="form-group">
<input class="form-control col-md-8" placeholder="Search" type="text">

+ 1
- 1
web/views/sankey/sankey.html

@ -16,7 +16,7 @@
</div>
</div>
</div>
<div class="col-sm-8">
<div class="col-sm-10">
<div class="panel-heading c_blueGrey300">
<h3 class="panel-title">Sankey - address {{selectedAddress}}</h3>
</div>

+ 1
- 1
web/views/sankey/sankey.js

@ -13,7 +13,7 @@ angular.module('app.sankey', ['ngRoute', 'ngSankey'])
$scope.selectedAddress = "";
$scope.options = {
chart: '#sankeyChart',
width: 960,
width: 800,
height: 500,
margin: {top: 1, right: 1, bottom: 6, left: 1},
node: {width: 15, padding :10, showValue: false},

Loading…
Cancel
Save