pool: even more refactoring.
This commit is contained in:
parent
54dd7c4eb3
commit
09d699109e
@ -416,7 +416,7 @@ Peer.prototype._onAck = function _onAck(err) {
|
|||||||
|
|
||||||
// Ask for the mempool if we're synced.
|
// Ask for the mempool if we're synced.
|
||||||
if (this.network.requestMempool) {
|
if (this.network.requestMempool) {
|
||||||
if (this.isLoader() && this.pool.synced)
|
if (this.isLoader() && this.chain.synced)
|
||||||
this.sendMempool();
|
this.sendMempool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1103,7 +1103,7 @@ Peer.prototype._handleGetUTXOs = function _handleGetUTXOs(payload) {
|
|||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.pool.synced)
|
if (!this.chain.synced)
|
||||||
return done();
|
return done();
|
||||||
|
|
||||||
if (this.options.selfish)
|
if (this.options.selfish)
|
||||||
@ -1187,7 +1187,7 @@ Peer.prototype._handleGetHeaders = function _handleGetHeaders(payload) {
|
|||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.pool.synced)
|
if (!this.chain.synced)
|
||||||
return done();
|
return done();
|
||||||
|
|
||||||
if (this.options.selfish)
|
if (this.options.selfish)
|
||||||
@ -1270,7 +1270,7 @@ Peer.prototype._handleGetBlocks = function _handleGetBlocks(payload) {
|
|||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.pool.synced)
|
if (!this.chain.synced)
|
||||||
return done();
|
return done();
|
||||||
|
|
||||||
if (this.options.selfish)
|
if (this.options.selfish)
|
||||||
@ -1414,7 +1414,7 @@ Peer.prototype._handleMempool = function _handleMempool() {
|
|||||||
if (!this.mempool)
|
if (!this.mempool)
|
||||||
return done();
|
return done();
|
||||||
|
|
||||||
if (!this.pool.synced)
|
if (!this.chain.synced)
|
||||||
return done();
|
return done();
|
||||||
|
|
||||||
if (this.options.selfish)
|
if (this.options.selfish)
|
||||||
@ -2390,7 +2390,7 @@ Peer.prototype.sync = function sync(callback) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this.isLoader()) {
|
if (!this.isLoader()) {
|
||||||
if (!this.chain.isFull())
|
if (!this.chain.synced)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,6 @@ function Pool(options) {
|
|||||||
this.identityKey = null;
|
this.identityKey = null;
|
||||||
|
|
||||||
this.syncing = false;
|
this.syncing = false;
|
||||||
this.synced = false;
|
|
||||||
|
|
||||||
this.loadTimeout = 120000;
|
this.loadTimeout = 120000;
|
||||||
|
|
||||||
@ -277,7 +276,7 @@ Pool.prototype._init = function _init() {
|
|||||||
self.stopTimeout();
|
self.stopTimeout();
|
||||||
self.stopInterval();
|
self.stopInterval();
|
||||||
|
|
||||||
if (!self.synced) {
|
if (!self.chain.synced) {
|
||||||
// Ask loader for a mempool snapshot.
|
// Ask loader for a mempool snapshot.
|
||||||
if (self.network.requestMempool) {
|
if (self.network.requestMempool) {
|
||||||
if (self.peers.load)
|
if (self.peers.load)
|
||||||
@ -288,7 +287,6 @@ Pool.prototype._init = function _init() {
|
|||||||
self.sync();
|
self.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.synced = true;
|
|
||||||
self.emit('full');
|
self.emit('full');
|
||||||
|
|
||||||
self.logger.info('Chain is fully synced (height=%d).', self.chain.height);
|
self.logger.info('Chain is fully synced (height=%d).', self.chain.height);
|
||||||
@ -412,7 +410,7 @@ Pool.prototype.connect = function connect() {
|
|||||||
// chain that we can't connect and
|
// chain that we can't connect and
|
||||||
// verify yet.
|
// verify yet.
|
||||||
this.chain.on('block', function(block) {
|
this.chain.on('block', function(block) {
|
||||||
if (!self.synced)
|
if (!self.chain.synced)
|
||||||
return;
|
return;
|
||||||
self.announce(block);
|
self.announce(block);
|
||||||
});
|
});
|
||||||
@ -537,7 +535,7 @@ Pool.prototype.startTimeout = function startTimeout() {
|
|||||||
if (!self.syncing)
|
if (!self.syncing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (self.chain.isFull())
|
if (self.chain.synced)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (self.peers.load) {
|
if (self.peers.load) {
|
||||||
@ -581,7 +579,7 @@ Pool.prototype.startInterval = function startInterval() {
|
|||||||
if (!self.syncing)
|
if (!self.syncing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (self.chain.isFull())
|
if (self.chain.synced)
|
||||||
return self.stopInterval();
|
return self.stopInterval();
|
||||||
|
|
||||||
if (self.chain.isBusy())
|
if (self.chain.isBusy())
|
||||||
@ -883,7 +881,7 @@ Pool.prototype._handleInv = function _handleInv(hashes, peer, callback) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Ignore for now if we're still syncing
|
// Ignore for now if we're still syncing
|
||||||
if (!this.synced && !peer.isLoader())
|
if (!this.chain.synced && !peer.isLoader())
|
||||||
return callback();
|
return callback();
|
||||||
|
|
||||||
if (!this.options.headers)
|
if (!this.options.headers)
|
||||||
@ -1182,7 +1180,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
|
|||||||
|
|
||||||
self.emit('txs', txs, peer);
|
self.emit('txs', txs, peer);
|
||||||
|
|
||||||
if (self.syncing && !self.synced)
|
if (self.syncing && !self.chain.synced)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < txs.length; i++) {
|
for (i = 0; i < txs.length; i++) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user