fix wallet hashes. do not request mempool on main.

This commit is contained in:
Christopher Jeffrey 2016-06-23 12:06:54 -07:00
parent 48855ae56f
commit d7db03daa3
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 23 additions and 15 deletions

View File

@ -311,8 +311,10 @@ Pool.prototype._init = function _init() {
if (!self.synced) {
// Ask loader for a mempool snapshot.
if (self.peers.load)
self.peers.load.sendMempool();
if (self.network.requestMempool) {
if (self.peers.load)
self.peers.load.sendMempool();
}
// Ask all peers for their latest blocks.
self.sync();
@ -1283,6 +1285,12 @@ Pool.prototype._addPeer = function _addPeer() {
});
};
/**
* Remove a peer from any list. Drop all load requests.
* @private
* @param {Peer} peer
*/
Pool.prototype._removePeer = function _removePeer(peer) {
utils.binaryRemove(this.peers.pending, peer, compare);
utils.binaryRemove(this.peers.regular, peer, compare);

View File

@ -695,7 +695,8 @@ Wallet.prototype.deriveInputs = function deriveInputs(tx, callback) {
Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) {
var self = this;
var paths = [];
var hashes;
var hashes = [];
var hash;
function done() {
utils.forEachSerial(hashes, function(hash, next, i) {
@ -718,7 +719,9 @@ Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) {
if (tx instanceof bcoin.input) {
if (!tx.coin)
return callback(new Error('Not all coins available.'));
hashes = [tx.coin.getHash('hex')];
hash = tx.coin.getHash('hex')
if (hash)
hashes.push(hash);
return done();
}
@ -743,12 +746,16 @@ Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) {
Wallet.prototype.getOutputPaths = function getOutputPaths(tx, callback) {
var self = this;
var paths = [];
var hashes;
var hashes = [];
var hash;
if (tx instanceof bcoin.output)
hashes = [tx.getHash('hex')];
else
if (tx instanceof bcoin.output) {
hash = tx.getHash('hex');
if (hash)
hashes.push(hash);
} else {
hashes = tx.getOutputHashes('hex');
}
utils.forEachSerial(hashes, function(hash, next, i) {
self.getPath(hash, function(err, path) {
@ -975,13 +982,6 @@ Wallet.prototype.sign = function sign(tx, options, callback) {
var total = 0;
var i, address, key, master;
if (Array.isArray(tx)) {
utils.forEachSerial(tx, function(tx, next) {
self.sign(tx, options, next);
}, callback);
return;
}
if (typeof options === 'function') {
callback = options;
options = {};