|
|
@ -46,13 +46,11 @@ function spec() { |
|
|
|
}; |
|
|
|
|
|
|
|
PeerSync.prototype.handle_inv = function(info) { |
|
|
|
// TODO: should limit the invs to objects we haven't seen yet
|
|
|
|
var invs = info.message.invs; |
|
|
|
invs.forEach(function(inv) { |
|
|
|
console.log('[p2p_sync] Handle inv for a ' + CoinConst.MSG.to_str(inv.type)); |
|
|
|
}); |
|
|
|
// this is not needed right now, but it's left in case
|
|
|
|
// we need to store more info in the future
|
|
|
|
// TODO: should limit the invs to objects we haven't seen yet
|
|
|
|
info.conn.sendGetData(invs); |
|
|
|
}; |
|
|
|
|
|
|
@ -69,12 +67,10 @@ function spec() { |
|
|
|
PeerSync.prototype.handle_block = function(info) { |
|
|
|
var self = this; |
|
|
|
var block = info.message.block; |
|
|
|
var now = Math.round(new Date().getTime() / 1000); |
|
|
|
var blockHash = coinUtil.formatHashFull(block.calcHash()); |
|
|
|
console.log('[p2p_sync] Handle block: ' + blockHash); |
|
|
|
this.sync.storeBlock({ |
|
|
|
'hash': blockHash, |
|
|
|
'time': now, |
|
|
|
'fromP2P': true, |
|
|
|
}, |
|
|
|
function(err) { |
|
|
|