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