Change name to sync on networkmonitor
This commit is contained in:
parent
abac6a9ed3
commit
13b4f41f80
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user