Strip attached coinbase transactions to save data.

This commit is contained in:
softsimon 2020-05-24 22:45:45 +07:00
parent ba007a4b17
commit 2c345426cb
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -76,7 +76,7 @@ class Blocks {
transactions.sort((a, b) => b.feePerVsize - a.feePerVsize);
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.coinbaseTx = transactions[0];
block.coinbaseTx = this.stripCoinbaseTransaction(transactions[0]);
this.blocks.push(block);
if (this.blocks.length > config.KEEP_BLOCK_AMOUNT) {
@ -90,6 +90,15 @@ class Blocks {
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();