Removed checkpoint from headers; it is not needed.
This commit is contained in:
parent
20179991fc
commit
0431353048
@ -291,7 +291,7 @@ BlockService.prototype._handleReorg = function(hash, allHeaders) {
|
||||
|
||||
this._reorging = true; // while this is set, we won't be sending blocks
|
||||
|
||||
log.warn('Block Serivce: Chain reorganization detected! Our current block tip is: ' +
|
||||
log.warn('Block Service: Chain reorganization detected! Our current block tip is: ' +
|
||||
this._tip.hash + ' the current block: ' + hash + '.');
|
||||
|
||||
this._findCommonAncestor(hash, allHeaders, function(err, newHash, commonAncestorHash, oldBlocks) {
|
||||
@ -482,7 +482,6 @@ BlockService.prototype._onBlock = function(block) {
|
||||
BlockService.prototype._setListeners = function() {
|
||||
|
||||
this._header.once('headers', this._onAllHeaders.bind(this));
|
||||
this._header.on('reorg', this._handleReorg.bind(this));
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ var HeaderService = function(options) {
|
||||
this._tip = null;
|
||||
this._p2p = this.node.services.p2p;
|
||||
this._db = this.node.services.db;
|
||||
this._checkpoint = this.node.checkpoint || 1000; // the # of header to look back on boot
|
||||
this._headers = new utils.SimpleMap();
|
||||
|
||||
this.subscriptions = {};
|
||||
@ -97,9 +96,6 @@ HeaderService.prototype.start = function(callback) {
|
||||
height: self._tip.height,
|
||||
hash: self._tip.hash
|
||||
};
|
||||
if (self._tip.height > self._checkpoint) {
|
||||
self._tip.height -= self._checkpoint;
|
||||
}
|
||||
if (self._tip.height === 0) {
|
||||
|
||||
var genesisHeader = {
|
||||
@ -248,11 +244,10 @@ HeaderService.prototype._onHeaders = function(headers) {
|
||||
log.debug('Header Service: download complete.');
|
||||
|
||||
// have we reorg'ed since we've been shutdown?
|
||||
if (self._originalTip.height > 0) {
|
||||
if (self._tip.height > 0) {
|
||||
|
||||
var headerHash = self._headers.getIndex(self._originalTip.height).hash;
|
||||
|
||||
if (self._originalTip.hash !== headerHash) {
|
||||
var headerHash = self._headers.getIndex(self._tip.height).hash;
|
||||
if (self._tip.hash !== headerHash) {
|
||||
|
||||
self.emit('reorg', headerHash, self._headers);
|
||||
return;
|
||||
@ -282,8 +277,7 @@ HeaderService.prototype._onBestHeight = function(height) {
|
||||
|
||||
HeaderService.prototype._startSync = function() {
|
||||
|
||||
this._numNeeded = Math.max(this._bestHeight - this._tip.height, this._checkpoint);
|
||||
|
||||
this._numNeeded = this._bestHeight - this._tip.height;
|
||||
|
||||
log.info('Header Service: Gathering: ' + this._numNeeded + ' ' + 'header(s) from the peer-to-peer network.');
|
||||
|
||||
@ -308,10 +302,11 @@ HeaderService.prototype._getPersistedHeaders = function(callback) {
|
||||
|
||||
var self = this;
|
||||
|
||||
|
||||
var start = self._encoding.encodeHeaderKey(0);
|
||||
var end = self._encoding.encodeHeaderKey(self._tip.height + 1);
|
||||
|
||||
log.debug('Getting persisted headers from genesis block to block ' + (self._tip.height + 1));
|
||||
|
||||
var criteria = {
|
||||
gte: start,
|
||||
lte: end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user