mempool: fix getDescendants and getAncestors.
This commit is contained in:
parent
bf4c890b88
commit
b53162e12d
@ -1037,7 +1037,7 @@ RPC.prototype.getmempoolancestors = co(function* getmempoolancestors(args, help)
|
||||
if (!entry)
|
||||
throw new RPCError('Transaction not in mempool.');
|
||||
|
||||
entries = this.mempool.getAncestors(entry.tx);
|
||||
entries = this.mempool.getAncestors(entry);
|
||||
|
||||
if (verbose) {
|
||||
for (i = 0; i < entries.length; i++) {
|
||||
@ -1047,7 +1047,7 @@ RPC.prototype.getmempoolancestors = co(function* getmempoolancestors(args, help)
|
||||
} else {
|
||||
for (i = 0; i < entries.length; i++) {
|
||||
entry = entries[i];
|
||||
out.push(entry.tx.txid());
|
||||
out.push(entry.txid());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1077,7 +1077,7 @@ RPC.prototype.getmempooldescendants = co(function* getmempooldescendants(args, h
|
||||
if (!entry)
|
||||
throw new RPCError('Transaction not in mempool.');
|
||||
|
||||
entries = this.mempool.getDescendants(entry.tx);
|
||||
entries = this.mempool.getDescendants(entry);
|
||||
|
||||
if (verbose) {
|
||||
for (i = 0; i < entries.length; i++) {
|
||||
@ -1087,7 +1087,7 @@ RPC.prototype.getmempooldescendants = co(function* getmempooldescendants(args, h
|
||||
} else {
|
||||
for (i = 0; i < entries.length; i++) {
|
||||
entry = entries[i];
|
||||
out.push(entry.tx.txid());
|
||||
out.push(entry.txid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1283,7 +1283,7 @@ Mempool.prototype._countDescendants = function countDescendants(entry, count, se
|
||||
if (!child)
|
||||
continue;
|
||||
|
||||
next = child.tx.hash('hex');
|
||||
next = child.hash('hex');
|
||||
|
||||
if (set[next])
|
||||
continue;
|
||||
@ -1299,30 +1299,31 @@ Mempool.prototype._countDescendants = function countDescendants(entry, count, se
|
||||
|
||||
/**
|
||||
* Get all transaction ancestors.
|
||||
* @param {TX} tx
|
||||
* @param {MempoolEntry} entry
|
||||
* @returns {MempoolEntry[]}
|
||||
*/
|
||||
|
||||
Mempool.prototype.getAncestors = function getAncestors(tx) {
|
||||
return this._getAncestors(tx, [], {});
|
||||
Mempool.prototype.getAncestors = function getAncestors(entry) {
|
||||
return this._getAncestors(entry, [], {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all transaction ancestors.
|
||||
* @private
|
||||
* @param {TX} tx
|
||||
* @param {MempoolEntry} entry
|
||||
* @param {MempoolEntry[]} entries
|
||||
* @param {Object} set
|
||||
* @returns {MempoolEntry[]}
|
||||
*/
|
||||
|
||||
Mempool.prototype._getAncestors = function getAncestors(tx, entries, set) {
|
||||
Mempool.prototype._getAncestors = function getAncestors(entry, entries, set) {
|
||||
var tx = entry.tx;
|
||||
var i, hash, input, parent;
|
||||
|
||||
for (i = 0; i < tx.inputs.length; i++) {
|
||||
input = tx.inputs[i];
|
||||
hash = input.prevout.hash;
|
||||
parent = this.getTX(hash);
|
||||
parent = this.getEntry(hash);
|
||||
|
||||
if (!parent)
|
||||
continue;
|
||||
@ -1341,28 +1342,29 @@ Mempool.prototype._getAncestors = function getAncestors(tx, entries, set) {
|
||||
|
||||
/**
|
||||
* Get all a transaction descendants.
|
||||
* @param {TX} tx
|
||||
* @param {MempoolEntry} entry
|
||||
* @returns {MempoolEntry[]}
|
||||
*/
|
||||
|
||||
Mempool.prototype.getDescendants = function getDescendants(tx) {
|
||||
return this._getDescendants(tx, [], {});
|
||||
Mempool.prototype.getDescendants = function getDescendants(entry) {
|
||||
return this._getDescendants(entry, [], {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all a transaction descendants.
|
||||
* @param {TX} tx
|
||||
* @param {MempoolEntry} entry
|
||||
* @param {MempoolEntry[]} entries
|
||||
* @param {Object} set
|
||||
* @returns {MempoolEntry[]}
|
||||
*/
|
||||
|
||||
Mempool.prototype._getDescendants = function getDescendants(tx, entries, set) {
|
||||
Mempool.prototype._getDescendants = function getDescendants(entry, entries, set) {
|
||||
var tx = entry.tx;
|
||||
var hash = tx.hash('hex');
|
||||
var i, child, next;
|
||||
|
||||
for (i = 0; i < tx.outputs.length; i++) {
|
||||
child = this.getSpentTX(hash, i);
|
||||
child = this.getSpent(hash, i);
|
||||
|
||||
if (!child)
|
||||
continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user