block: remove addTX.
This commit is contained in:
parent
8c212d797f
commit
cd795cf96f
@ -2506,7 +2506,7 @@ Pool.prototype._handleTX = async function handleTX(peer, packet) {
|
|||||||
|
|
||||||
peer.merkleMap.add(hash);
|
peer.merkleMap.add(hash);
|
||||||
|
|
||||||
block.addTX(tx);
|
block.txs.push(tx);
|
||||||
|
|
||||||
if (--peer.merkleMatches === 0) {
|
if (--peer.merkleMatches === 0) {
|
||||||
peer.merkleBlock = null;
|
peer.merkleBlock = null;
|
||||||
|
|||||||
@ -58,8 +58,10 @@ Block.prototype.fromOptions = function fromOptions(options) {
|
|||||||
|
|
||||||
if (options.txs) {
|
if (options.txs) {
|
||||||
assert(Array.isArray(options.txs));
|
assert(Array.isArray(options.txs));
|
||||||
for (let tx of options.txs)
|
for (let tx of options.txs) {
|
||||||
this.addTX(tx);
|
assert(tx instanceof TX);
|
||||||
|
this.txs.push(tx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -243,16 +245,6 @@ Block.prototype.hasWitness = function hasWitness() {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a transaction to the block's tx vector.
|
|
||||||
* @param {TX} tx
|
|
||||||
* @returns {Number}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Block.prototype.addTX = function addTX(tx) {
|
|
||||||
return this.txs.push(tx) - 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the block's transaction vector against a hash.
|
* Test the block's transaction vector against a hash.
|
||||||
* @param {Hash} hash
|
* @param {Hash} hash
|
||||||
@ -660,7 +652,7 @@ Block.prototype.fromReader = function fromReader(br) {
|
|||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
let tx = TX.fromReader(br);
|
let tx = TX.fromReader(br);
|
||||||
witness += tx._witness;
|
witness += tx._witness;
|
||||||
this.addTX(tx);
|
this.txs.push(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.mutable) {
|
if (!this.mutable) {
|
||||||
|
|||||||
@ -107,22 +107,6 @@ MerkleBlock.prototype.refresh = function refresh(all) {
|
|||||||
tx.refresh();
|
tx.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a transaction to the block's tx vector.
|
|
||||||
* @param {TX} tx
|
|
||||||
* @returns {Number}
|
|
||||||
*/
|
|
||||||
|
|
||||||
MerkleBlock.prototype.addTX = function addTX(tx) {
|
|
||||||
let tree = this.getTree();
|
|
||||||
let hash = tx.hash('hex');
|
|
||||||
let index = tree.map.get(hash);
|
|
||||||
|
|
||||||
this.txs.push(tx);
|
|
||||||
|
|
||||||
return index != null ? index : -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the block's _matched_ transaction vector against a hash.
|
* Test the block's _matched_ transaction vector against a hash.
|
||||||
* @param {Hash} hash
|
* @param {Hash} hash
|
||||||
|
|||||||
@ -68,7 +68,7 @@ function createGenesisBlock(options) {
|
|||||||
height: 0
|
height: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
block.addTX(tx);
|
block.txs.push(tx);
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user