|
|
|
@ -2,13 +2,15 @@ var _ = require('lodash'); |
|
|
|
|
var Blockchain = require('./history'); |
|
|
|
|
var Node = require('./node'); |
|
|
|
|
|
|
|
|
|
var Collection = function Collection() |
|
|
|
|
var Collection = function Collection(externalAPI) |
|
|
|
|
{ |
|
|
|
|
this._items = []; |
|
|
|
|
this._blockchain = new Blockchain(); |
|
|
|
|
this._askedForHistory = false; |
|
|
|
|
this._askedForHistoryTime = 0; |
|
|
|
|
this._debounced = null; |
|
|
|
|
this._externalAPI = externalAPI; |
|
|
|
|
this._highestBlock = 0; |
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
@ -76,6 +78,15 @@ Collection.prototype.addBlock = function(id, stats, callback) |
|
|
|
|
stats.received = block.block.received; |
|
|
|
|
stats.propagation = block.block.propagation; |
|
|
|
|
|
|
|
|
|
if(block.block.number > this._highestBlock) |
|
|
|
|
{ |
|
|
|
|
this._highestBlock = block.block.number; |
|
|
|
|
this._externalAPI.write({ |
|
|
|
|
action:"bestBlock", |
|
|
|
|
number: this._highestBlock |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
node.setBlock(stats, propagationHistory, callback); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|