pool: even more refactoring.

This commit is contained in:
Christopher Jeffrey 2016-08-26 01:13:46 -07:00
parent 54dd7c4eb3
commit 09d699109e
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 12 additions and 14 deletions

View File

@ -416,7 +416,7 @@ Peer.prototype._onAck = function _onAck(err) {
// Ask for the mempool if we're synced.
if (this.network.requestMempool) {
if (this.isLoader() && this.pool.synced)
if (this.isLoader() && this.chain.synced)
this.sendMempool();
}
@ -1103,7 +1103,7 @@ Peer.prototype._handleGetUTXOs = function _handleGetUTXOs(payload) {
unlock();
}
if (!this.pool.synced)
if (!this.chain.synced)
return done();
if (this.options.selfish)
@ -1187,7 +1187,7 @@ Peer.prototype._handleGetHeaders = function _handleGetHeaders(payload) {
unlock();
}
if (!this.pool.synced)
if (!this.chain.synced)
return done();
if (this.options.selfish)
@ -1270,7 +1270,7 @@ Peer.prototype._handleGetBlocks = function _handleGetBlocks(payload) {
unlock();
}
if (!this.pool.synced)
if (!this.chain.synced)
return done();
if (this.options.selfish)
@ -1414,7 +1414,7 @@ Peer.prototype._handleMempool = function _handleMempool() {
if (!this.mempool)
return done();
if (!this.pool.synced)
if (!this.chain.synced)
return done();
if (this.options.selfish)
@ -2390,7 +2390,7 @@ Peer.prototype.sync = function sync(callback) {
return;
if (!this.isLoader()) {
if (!this.chain.isFull())
if (!this.chain.synced)
return;
}

View File

@ -106,7 +106,6 @@ function Pool(options) {
this.identityKey = null;
this.syncing = false;
this.synced = false;
this.loadTimeout = 120000;
@ -277,7 +276,7 @@ Pool.prototype._init = function _init() {
self.stopTimeout();
self.stopInterval();
if (!self.synced) {
if (!self.chain.synced) {
// Ask loader for a mempool snapshot.
if (self.network.requestMempool) {
if (self.peers.load)
@ -288,7 +287,6 @@ Pool.prototype._init = function _init() {
self.sync();
}
self.synced = true;
self.emit('full');
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
// verify yet.
this.chain.on('block', function(block) {
if (!self.synced)
if (!self.chain.synced)
return;
self.announce(block);
});
@ -537,7 +535,7 @@ Pool.prototype.startTimeout = function startTimeout() {
if (!self.syncing)
return;
if (self.chain.isFull())
if (self.chain.synced)
return;
if (self.peers.load) {
@ -581,7 +579,7 @@ Pool.prototype.startInterval = function startInterval() {
if (!self.syncing)
return;
if (self.chain.isFull())
if (self.chain.synced)
return self.stopInterval();
if (self.chain.isBusy())
@ -883,7 +881,7 @@ Pool.prototype._handleInv = function _handleInv(hashes, peer, callback) {
return;
// Ignore for now if we're still syncing
if (!this.synced && !peer.isLoader())
if (!this.chain.synced && !peer.isLoader())
return callback();
if (!this.options.headers)
@ -1182,7 +1180,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
self.emit('txs', txs, peer);
if (self.syncing && !self.synced)
if (self.syncing && !self.chain.synced)
return;
for (i = 0; i < txs.length; i++) {