Strip attached coinbase transactions to save data.
This commit is contained in:
parent
ba007a4b17
commit
2c345426cb
@ -76,7 +76,7 @@ class Blocks {
|
|||||||
transactions.sort((a, b) => b.feePerVsize - a.feePerVsize);
|
transactions.sort((a, b) => b.feePerVsize - a.feePerVsize);
|
||||||
block.medianFee = transactions.length > 1 ? Common.median(transactions.map((tx) => tx.feePerVsize)) : 0;
|
block.medianFee = transactions.length > 1 ? Common.median(transactions.map((tx) => tx.feePerVsize)) : 0;
|
||||||
block.feeRange = transactions.length > 1 ? Common.getFeesInRange(transactions, 8) : [0, 0];
|
block.feeRange = transactions.length > 1 ? Common.getFeesInRange(transactions, 8) : [0, 0];
|
||||||
block.coinbaseTx = transactions[0];
|
block.coinbaseTx = this.stripCoinbaseTransaction(transactions[0]);
|
||||||
|
|
||||||
this.blocks.push(block);
|
this.blocks.push(block);
|
||||||
if (this.blocks.length > config.KEEP_BLOCK_AMOUNT) {
|
if (this.blocks.length > config.KEEP_BLOCK_AMOUNT) {
|
||||||
@ -90,6 +90,15 @@ class Blocks {
|
|||||||
console.log('updateBlocks error', err);
|
console.log('updateBlocks error', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private stripCoinbaseTransaction(tx: TransactionExtended): any {
|
||||||
|
return {
|
||||||
|
vin: [{
|
||||||
|
scriptsig: tx.vin[0].scriptsig
|
||||||
|
}],
|
||||||
|
vout: tx.vout.map((vout) => ({ scriptpubkey_address: vout.scriptpubkey_address }))
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Blocks();
|
export default new Blocks();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user