mempool: tx deps.

This commit is contained in:
Christopher Jeffrey 2016-06-09 05:43:23 -07:00
parent 97fc0b60f5
commit 610ecde401
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1795,6 +1795,7 @@ function MempoolEntry(options) {
this.count = options.count;
this.size = options.size;
this.fees = options.fees;
this.dependencies = options.dependencies;
}
/**
@ -1806,6 +1807,15 @@ function MempoolEntry(options) {
MempoolEntry.fromTX = function fromTX(tx, height) {
var data = tx.getPriority(height);
var dependencies = false;
var i;
for (i = 0; i < tx.inputs.length; i++) {
if (tx.inputs[i].coin.height === -1) {
dependencies = true;
break;
}
}
return new MempoolEntry({
tx: tx,
@ -1815,7 +1825,8 @@ MempoolEntry.fromTX = function fromTX(tx, height) {
ts: utils.now(),
count: 1,
size: tx.getVirtualSize(),
fees: tx.getFee()
fees: tx.getFee(),
dependencies: dependencies
});
};
@ -1839,6 +1850,7 @@ MempoolEntry.prototype.toRaw = function toRaw(writer) {
p.writeU32(this.count);
p.writeU32(this.size);
p.writeVarint(this.fees);
p.writeU8(this.dependencies ? 1 : 0);
if (!writer)
p = p.render();
@ -1862,7 +1874,8 @@ MempoolEntry.fromRaw = function fromRaw(data) {
ts: p.readU32(),
count: p.readU32(),
size: p.readU32(),
fees: p.readVarint()
fees: p.readVarint(),
dependencies: p.readU8() === 1
});
};