Change name to sync on networkmonitor

This commit is contained in:
eordano 2015-04-06 15:14:12 -03:00
parent abac6a9ed3
commit 13b4f41f80
2 changed files with 9 additions and 6 deletions

View File

@ -64,6 +64,11 @@ NetworkMonitor.prototype.setupPeer = function(peer) {
};
NetworkMonitor.prototype.requestBlocks = function(start) {
$.checkArgument(_.isString(start), 'start must be a block hash string');
this.peer.sendMessage(messages.GetBlocks([start]));
};
NetworkMonitor.prototype.start = function() {
this.peer.connect();
};
@ -76,9 +81,4 @@ NetworkMonitor.prototype.abort = function(reason) {
throw reason;
};
NetworkMonitor.prototype.syncFrom = function(start) {
$.checkArgument(_.isString(start), 'start must be a block hash string');
this.peer.sendMessage(messages.GetBlocks([start]));
};
module.exports = NetworkMonitor;

View File

@ -28,6 +28,8 @@ var BitcoreNode = function(bus, networkMonitor, blockService, transactionService
this.bus = bus;
this.networkMonitor = networkMonitor;
this.tip = null;
this.addressService = addressService;
this.transactionService = transactionService;
this.blockService = blockService;
@ -95,7 +97,8 @@ BitcoreNode.prototype.sync = function() {
start = latest.hash;
}
console.log('Starting sync from', start);
self.networkMonitor.syncFrom(start);
self.tip = latest;
self.networkMonitor.requestBlocks(start);
})
.catch(function(err) {
self.networkMonitor.stop();