fixed address tree concurrent generation algorithm

This commit is contained in:
arnaucode
2017-08-15 09:36:17 +02:00
parent 42bfe7cda1
commit ff774543e8
12 changed files with 40 additions and 20 deletions

View File

@@ -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")

View File

@@ -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 {

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

@@ -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
}
}

View File

@@ -12,6 +12,7 @@ type Config struct {
Port string `json:"port"`
GenesisTx string `json:"genesisTx"`
GenesisBlock string `json:"genesisBlock"`
StartFromBlock int64 `json:"startFromBlock"`
}
var config Config

View File

@@ -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

View File

@@ -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>

View File

@@ -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">

View File

@@ -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>

View File

@@ -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},