diff --git a/DevelopmentNotes.md b/DevelopmentNotes.md index 6049511..82d6755 100644 --- a/DevelopmentNotes.md +++ b/DevelopmentNotes.md @@ -33,3 +33,12 @@ other - fix error in exploreBlockchain.go, when getting the tx.Vin tx 8f04960da36beaa928b9693f7dca4afae5a6122bb6874d409a1156e4c6c55024 has 4 vin, but exploreBlockchain is only getting the first + +- pagination in address network generation + +- stop rendering dots of sankey, when view change + +- sidebar pages: + list of addresses in fairmarket (addresses of shops), to view statistics in time of the inputs and outputs in a timeline + +- refresh blockchain database every minute diff --git a/screenshots/new/goBlockchainDataAnalysis00.png b/screenshots/new/goBlockchainDataAnalysis00.png new file mode 100644 index 0000000..0cd308c Binary files /dev/null and b/screenshots/new/goBlockchainDataAnalysis00.png differ diff --git a/screenshots/new/goBlockchainDataAnalysis01png b/screenshots/new/goBlockchainDataAnalysis01png new file mode 100644 index 0000000..729036b Binary files /dev/null and b/screenshots/new/goBlockchainDataAnalysis01png differ diff --git a/screenshots/new/goBlockchainDataAnalysis02.png b/screenshots/new/goBlockchainDataAnalysis02.png new file mode 100644 index 0000000..dfc2b3b Binary files /dev/null and b/screenshots/new/goBlockchainDataAnalysis02.png differ diff --git a/serverRoutes.go b/serverRoutes.go index 44cd036..6ecc6b0 100644 --- a/serverRoutes.go +++ b/serverRoutes.go @@ -35,16 +35,22 @@ var routes = Routes{ AllAddresses, }, Route{ - "GetLastAddr", + "Blocks", "Get", - "/lastaddr", - GetLastAddr, + "/blocks/{page}/{count}", + Blocks, }, Route{ - "GetLastTx", + "Txs", "Get", - "/lasttx", - GetLastTx, + "/txs/{page}/{count}", + Txs, + }, + Route{ + "Addresses", + "Get", + "/addresses/{page}/{count}", + Addresses, }, Route{ "Block", @@ -171,24 +177,42 @@ func AllAddresses(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, string(jsonNodes)) } -func GetLastAddr(w http.ResponseWriter, r *http.Request) { +func Blocks(w http.ResponseWriter, r *http.Request) { ipFilter(w, r) + vars := mux.Vars(r) + page, err := strconv.Atoi(vars["page"]) + check(err) + count, err := strconv.Atoi(vars["count"]) + check(err) - addresses := []AddressModel{} - err := addressCollection.Find(bson.M{}).Limit(10).Sort("-$natural").All(&addresses) + blocks := []BlockModel{} + err = blockCollection.Find(bson.M{}).Skip((page - 1) * 20).Limit(count).Sort("-$natural").All(&blocks) check(err) + for _, block := range blocks { + //blockheight := strconv.FormatInt(block.Height, 10) + blockheight := block.Height + txs := []TxModel{} + err = txCollection.Find(bson.M{"blockheight": blockheight}).All(&txs) + block.Txs = txs + } + //convert []resp struct to json - jsonResp, err := json.Marshal(addresses) + jsonData, err := json.Marshal(blocks) check(err) - fmt.Fprintln(w, string(jsonResp)) + fmt.Fprintln(w, string(jsonData)) } -func GetLastTx(w http.ResponseWriter, r *http.Request) { +func Txs(w http.ResponseWriter, r *http.Request) { ipFilter(w, r) + vars := mux.Vars(r) + page, err := strconv.Atoi(vars["page"]) + check(err) + count, err := strconv.Atoi(vars["count"]) + check(err) txs := []TxModel{} - err := txCollection.Find(bson.M{}).Limit(10).Sort("-$natural").All(&txs) + err = txCollection.Find(bson.M{}).Skip((page - 1) * 20).Limit(count).Sort("-$natural").All(&txs) check(err) //convert []resp struct to json @@ -197,6 +221,24 @@ func GetLastTx(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, string(jsonData)) } +func Addresses(w http.ResponseWriter, r *http.Request) { + ipFilter(w, r) + vars := mux.Vars(r) + page, err := strconv.Atoi(vars["page"]) + check(err) + count, err := strconv.Atoi(vars["count"]) + check(err) + + addresses := []AddressModel{} + err = addressCollection.Find(bson.M{}).Skip((page - 1) * 20).Limit(count).Sort("-$natural").All(&addresses) + check(err) + + //convert []resp struct to json + jsonResp, err := json.Marshal(addresses) + check(err) + + fmt.Fprintln(w, string(jsonResp)) +} func Block(w http.ResponseWriter, r *http.Request) { ipFilter(w, r) diff --git a/web/views/addresses/addresses.html b/web/views/addresses/addresses.html index a6a7ddc..ea81030 100644 --- a/web/views/addresses/addresses.html +++ b/web/views/addresses/addresses.html @@ -10,6 +10,12 @@ {{address.hash}} + +
diff --git a/web/views/addresses/addresses.js b/web/views/addresses/addresses.js index 42fe3fc..50aad96 100644 --- a/web/views/addresses/addresses.js +++ b/web/views/addresses/addresses.js @@ -13,12 +13,25 @@ angular.module('app.addresses', ['ngRoute']) //last addr $scope.addresses = []; - $http.get(urlapi + 'lastaddr') - .then(function(data, status, headers, config) { - console.log(data); - $scope.addresses = data.data; - }, function(data, status, headers, config) { - console.log('data error'); - }); + $scope.page = 1; + $scope.count = 10; + $scope.getAddresses = function() { + $http.get(urlapi + 'addresses/' + $scope.page + '/' + $scope.count) + .then(function(data, status, headers, config) { + console.log(data); + $scope.addresses = data.data; + }, function(data, status, headers, config) { + console.log('data error'); + }); + }; + $scope.getAddresses(); + $scope.getPrev = function(){ + $scope.page++; + $scope.getAddresses(); + }; + $scope.getNext = function(){ + $scope.page--; + $scope.getAddresses(); + }; }); diff --git a/web/views/blocks/blocks.html b/web/views/blocks/blocks.html index 94a0789..14c18e3 100644 --- a/web/views/blocks/blocks.html +++ b/web/views/blocks/blocks.html @@ -2,7 +2,10 @@