misc sync fixes.
This commit is contained in:
parent
5ab48378cc
commit
b0ee614432
@ -1572,6 +1572,7 @@ Usage: `bcoin.tx([options], [block])`
|
|||||||
- __fill(wallet/txpool/object)__ - Fills all the transaction's inputs with the
|
- __fill(wallet/txpool/object)__ - Fills all the transaction's inputs with the
|
||||||
appropriate previous outputs using the available transactions in a wallet,
|
appropriate previous outputs using the available transactions in a wallet,
|
||||||
txpool, or an object with txids as its keys and txs as its values.
|
txpool, or an object with txids as its keys and txs as its values.
|
||||||
|
- __isFull()__ - Returns true if the TX has all previous output references.
|
||||||
- __isFinal(height, ts)__ - Mimics the bitcoind `IsFinalTx()` function. Checks
|
- __isFinal(height, ts)__ - Mimics the bitcoind `IsFinalTx()` function. Checks
|
||||||
the locktime and input sequences. Returns true or false.
|
the locktime and input sequences. Returns true or false.
|
||||||
- __getSigops([scripthash], [accurate])__ - Count sigops in transaction. Set
|
- __getSigops([scripthash], [accurate])__ - Count sigops in transaction. Set
|
||||||
|
|||||||
@ -123,7 +123,6 @@ Peer.prototype._init = function init() {
|
|||||||
self._error(err);
|
self._error(err);
|
||||||
// Something is wrong here.
|
// Something is wrong here.
|
||||||
// Ignore this peer.
|
// Ignore this peer.
|
||||||
self.destroy();
|
|
||||||
self.pool.misbehaving(self, 100);
|
self.pool.misbehaving(self, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -146,7 +145,6 @@ Peer.prototype._init = function init() {
|
|||||||
if (err) {
|
if (err) {
|
||||||
self._error(err);
|
self._error(err);
|
||||||
self.destroy();
|
self.destroy();
|
||||||
self.pool.misbehaving(self, 100);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.ack = true;
|
self.ack = true;
|
||||||
|
|||||||
@ -242,6 +242,7 @@ Pool.prototype._startTimer = function _startTimer() {
|
|||||||
// Chain is full and up-to-date
|
// Chain is full and up-to-date
|
||||||
if (self.chain.isFull()) {
|
if (self.chain.isFull()) {
|
||||||
self._stopTimer();
|
self._stopTimer();
|
||||||
|
self._stopInterval();
|
||||||
self.synced = true;
|
self.synced = true;
|
||||||
self.emit('full');
|
self.emit('full');
|
||||||
utils.debug('Chain is fully synced (height=%d).', self.chain.height());
|
utils.debug('Chain is fully synced (height=%d).', self.chain.height());
|
||||||
@ -346,11 +347,10 @@ Pool.prototype._addLoader = function _addLoader() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
peer.once('ack', function() {
|
peer.once('ack', function() {
|
||||||
|
peer.updateWatch();
|
||||||
if (!self.syncing)
|
if (!self.syncing)
|
||||||
return;
|
return;
|
||||||
peer.updateWatch();
|
self._load();
|
||||||
if (!self._load())
|
|
||||||
self._stopTimer();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
peer.on('merkleblock', function(block) {
|
peer.on('merkleblock', function(block) {
|
||||||
@ -410,10 +410,8 @@ Pool.prototype.startSync = function startSync() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.peers.load.ack) {
|
if (this.peers.load.ack)
|
||||||
if (!this._load())
|
this._load();
|
||||||
this._stopTimer();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype.stopSync = function stopSync() {
|
Pool.prototype.stopSync = function stopSync() {
|
||||||
@ -693,19 +691,17 @@ Pool.prototype._load = function _load() {
|
|||||||
var next;
|
var next;
|
||||||
|
|
||||||
if (!this.syncing)
|
if (!this.syncing)
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
if (!this.peers.load) {
|
if (!this.peers.load) {
|
||||||
this._addLoader();
|
this._addLoader();
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.headers)
|
if (this.options.headers)
|
||||||
this.peers.load.loadHeaders(this.chain.locatorHashes(), null);
|
this.peers.load.loadHeaders(this.chain.locatorHashes(), null);
|
||||||
else
|
else
|
||||||
this.peers.load.loadBlocks(this.chain.locatorHashes(), null);
|
this.peers.load.loadBlocks(this.chain.locatorHashes(), null);
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype.loadMempool = function loadMempool() {
|
Pool.prototype.loadMempool = function loadMempool() {
|
||||||
@ -1447,7 +1443,7 @@ Pool.prototype.sendTX = function sendTX(tx) {
|
|||||||
// bitcoind nodes. Possibly check
|
// bitcoind nodes. Possibly check
|
||||||
// sigops. Call isStandard and/or
|
// sigops. Call isStandard and/or
|
||||||
// isStandardInputs as well.
|
// isStandardInputs as well.
|
||||||
if (tx.full()) {
|
if (tx.isFull()) {
|
||||||
if (!tx.verify(null, true)) {
|
if (!tx.verify(null, true)) {
|
||||||
utils.debug(
|
utils.debug(
|
||||||
'Could not relay TX (%s). It does not verify.',
|
'Could not relay TX (%s). It does not verify.',
|
||||||
@ -1606,7 +1602,7 @@ Pool.prototype.getSeed = function getSeed(priority, connecting) {
|
|||||||
utils.debug(
|
utils.debug(
|
||||||
'We had to connect to a random peer. Something is not right.');
|
'We had to connect to a random peer. Something is not right.');
|
||||||
|
|
||||||
return seeds[Math.random() * (seeds.length - 1) | 0];
|
return original[Math.random() * (original.length - 1) | 0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1130,7 +1130,7 @@ TX.prototype.increaseFee = function increaseFee(fee) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TX.prototype.full = function full() {
|
TX.prototype.isFull = function isFull() {
|
||||||
if (this.inputs.length === 0)
|
if (this.inputs.length === 0)
|
||||||
return false;
|
return false;
|
||||||
return this.inputs.every(function(input) {
|
return this.inputs.every(function(input) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user