mirror of
https://github.com/arnaucube/goBlockchainDataAnalysis.git
synced 2026-02-06 19:26:41 +01:00
small update: integrated webserver in the main.go, small frontend changes, not finished relation loops bug fix
This commit is contained in:
15
README.md
15
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
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
BIN
goBlockchainDataAnalysis
Executable file
BIN
goBlockchainDataAnalysis
Executable file
Binary file not shown.
8
main.go
8
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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 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>
|
||||
|
||||
@@ -71,8 +71,10 @@ angular.module('app.addressNetwork', ['ngRoute'])
|
||||
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');
|
||||
|
||||
@@ -2,32 +2,32 @@
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user