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);
|
||||
|
||||
block.addTX(tx);
|
||||
block.txs.push(tx);
|
||||
|
||||
if (--peer.merkleMatches === 0) {
|
||||
peer.merkleBlock = null;
|
||||
|
||||
@ -58,8 +58,10 @@ Block.prototype.fromOptions = function fromOptions(options) {
|
||||
|
||||
if (options.txs) {
|
||||
assert(Array.isArray(options.txs));
|
||||
for (let tx of options.txs)
|
||||
this.addTX(tx);
|
||||
for (let tx of options.txs) {
|
||||
assert(tx instanceof TX);
|
||||
this.txs.push(tx);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -243,16 +245,6 @@ Block.prototype.hasWitness = function hasWitness() {
|
||||
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.
|
||||
* @param {Hash} hash
|
||||
@ -660,7 +652,7 @@ Block.prototype.fromReader = function fromReader(br) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
let tx = TX.fromReader(br);
|
||||
witness += tx._witness;
|
||||
this.addTX(tx);
|
||||
this.txs.push(tx);
|
||||
}
|
||||
|
||||
if (!this.mutable) {
|
||||
|
||||
@ -107,22 +107,6 @@ MerkleBlock.prototype.refresh = function refresh(all) {
|
||||
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.
|
||||
* @param {Hash} hash
|
||||
|
||||
@ -68,7 +68,7 @@ function createGenesisBlock(options) {
|
||||
height: 0
|
||||
});
|
||||
|
||||
block.addTX(tx);
|
||||
block.txs.push(tx);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user