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
|
||||
appropriate previous outputs using the available transactions in a wallet,
|
||||
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
|
||||
the locktime and input sequences. Returns true or false.
|
||||
- __getSigops([scripthash], [accurate])__ - Count sigops in transaction. Set
|
||||
|
||||
@ -123,7 +123,6 @@ Peer.prototype._init = function init() {
|
||||
self._error(err);
|
||||
// Something is wrong here.
|
||||
// Ignore this peer.
|
||||
self.destroy();
|
||||
self.pool.misbehaving(self, 100);
|
||||
});
|
||||
|
||||
@ -146,7 +145,6 @@ Peer.prototype._init = function init() {
|
||||
if (err) {
|
||||
self._error(err);
|
||||
self.destroy();
|
||||
self.pool.misbehaving(self, 100);
|
||||
return;
|
||||
}
|
||||
self.ack = true;
|
||||
|
||||
@ -242,6 +242,7 @@ Pool.prototype._startTimer = function _startTimer() {
|
||||
// Chain is full and up-to-date
|
||||
if (self.chain.isFull()) {
|
||||
self._stopTimer();
|
||||
self._stopInterval();
|
||||
self.synced = true;
|
||||
self.emit('full');
|
||||
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.updateWatch();
|
||||
if (!self.syncing)
|
||||
return;
|
||||
peer.updateWatch();
|
||||
if (!self._load())
|
||||
self._stopTimer();
|
||||
self._load();
|
||||
});
|
||||
|
||||
peer.on('merkleblock', function(block) {
|
||||
@ -410,10 +410,8 @@ Pool.prototype.startSync = function startSync() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.peers.load.ack) {
|
||||
if (!this._load())
|
||||
this._stopTimer();
|
||||
}
|
||||
if (this.peers.load.ack)
|
||||
this._load();
|
||||
};
|
||||
|
||||
Pool.prototype.stopSync = function stopSync() {
|
||||
@ -693,19 +691,17 @@ Pool.prototype._load = function _load() {
|
||||
var next;
|
||||
|
||||
if (!this.syncing)
|
||||
return true;
|
||||
return;
|
||||
|
||||
if (!this.peers.load) {
|
||||
this._addLoader();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.options.headers)
|
||||
this.peers.load.loadHeaders(this.chain.locatorHashes(), null);
|
||||
else
|
||||
this.peers.load.loadBlocks(this.chain.locatorHashes(), null);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
Pool.prototype.loadMempool = function loadMempool() {
|
||||
@ -1447,7 +1443,7 @@ Pool.prototype.sendTX = function sendTX(tx) {
|
||||
// bitcoind nodes. Possibly check
|
||||
// sigops. Call isStandard and/or
|
||||
// isStandardInputs as well.
|
||||
if (tx.full()) {
|
||||
if (tx.isFull()) {
|
||||
if (!tx.verify(null, true)) {
|
||||
utils.debug(
|
||||
'Could not relay TX (%s). It does not verify.',
|
||||
@ -1606,7 +1602,7 @@ Pool.prototype.getSeed = function getSeed(priority, connecting) {
|
||||
utils.debug(
|
||||
'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)
|
||||
return false;
|
||||
return this.inputs.every(function(input) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user