Put reportStatus on ProcessSerial.
This commit is contained in:
parent
b6f56fb02b
commit
ce09b816bb
@ -39,6 +39,7 @@ function ProcessSerial(highWaterMark, db, tip) {
|
|||||||
this.db = db;
|
this.db = db;
|
||||||
this.tip = tip;
|
this.tip = tip;
|
||||||
this.processBlockStartTime = [];
|
this.processBlockStartTime = [];
|
||||||
|
this._lastReportedTime = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(ProcessSerial, Writable);
|
inherits(ProcessSerial, Writable);
|
||||||
@ -65,7 +66,6 @@ function Sync(node, db) {
|
|||||||
this.syncing = false;
|
this.syncing = false;
|
||||||
this.paused = false; //we can't sync while one of our indexes is reading/writing separate from us
|
this.paused = false; //we can't sync while one of our indexes is reading/writing separate from us
|
||||||
this.highWaterMark = 10;
|
this.highWaterMark = 10;
|
||||||
this._lastReportedTime = Date.now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(Sync, EventEmitter);
|
inherits(Sync, EventEmitter);
|
||||||
@ -114,7 +114,6 @@ Sync.prototype._onFinish = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self._startSubscriptions();
|
self._startSubscriptions();
|
||||||
self._reportStatus(true);
|
|
||||||
self.emit('synced');
|
self.emit('synced');
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -129,7 +128,6 @@ Sync.prototype._startSubscriptions = function() {
|
|||||||
self.bus = self.node.openBus({remoteAddress: 'localhost'});
|
self.bus = self.node.openBus({remoteAddress: 'localhost'});
|
||||||
|
|
||||||
self.bus.on('bitcoind/hashblock', function() {
|
self.bus.on('bitcoind/hashblock', function() {
|
||||||
self._reportStatus();
|
|
||||||
self.sync();
|
self.sync();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,13 +136,6 @@ Sync.prototype._startSubscriptions = function() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Sync.prototype._reportStatus = function(override) {
|
|
||||||
if (((Date.now() - this._lastReportedTime) > 1000) || override) {
|
|
||||||
this._lastReportedTime = Date.now();
|
|
||||||
log.info('Sync: current height is: ' + this.db.tip.__height);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Sync.prototype._handleErrors = function(stream) {
|
Sync.prototype._handleErrors = function(stream) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -244,6 +235,13 @@ BlockStream.prototype._getBlocks = function(heights, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ProcessSerial.prototype._reportStatus = function() {
|
||||||
|
if ((Date.now() - this._lastReportedTime) > 1000) {
|
||||||
|
this._lastReportedTime = Date.now();
|
||||||
|
log.info('Sync: current height is: ' + this.db.tip.__height);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ProcessSerial.prototype._write = function(block, enc, callback) {
|
ProcessSerial.prototype._write = function(block, enc, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -288,6 +286,7 @@ ProcessSerial.prototype._process = function(block, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.db.tip = block;
|
self.db.tip = block;
|
||||||
|
self._reportStatus();
|
||||||
self.db.emit('addblock');
|
self.db.emit('addblock');
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user