From 2c345426cb2af4ca44d8b916fecd2bf8370dc376 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 24 May 2020 22:45:45 +0700 Subject: [PATCH] Strip attached coinbase transactions to save data. --- backend/src/api/blocks.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index e4e16af3d..9372f8039 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -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();