Compute median fee and fee percentiles in sats
This commit is contained in:
@@ -203,10 +203,13 @@ class Blocks {
|
||||
blk.extras.segwitTotalWeight = stats.swtotal_weight;
|
||||
}
|
||||
|
||||
blk.extras.feePercentiles = [], // TODO
|
||||
blk.extras.medianFeeAmt = 0; // TODO
|
||||
blk.extras.blockTime = 0; // TODO
|
||||
blk.extras.orphaned = false; // TODO
|
||||
|
||||
blk.extras.feePercentiles = await BlocksSummariesRepository.$getFeePercentilesByBlockId(block.id);
|
||||
if (blk.extras.feePercentiles !== null) {
|
||||
blk.extras.medianFeeAmt = blk.extras.feePercentiles[3];
|
||||
}
|
||||
|
||||
blk.extras.virtualSize = block.weight / 4.0;
|
||||
if (blk.extras.coinbaseTx.vout.length > 0) {
|
||||
@@ -791,7 +794,6 @@ class Blocks {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
delete(block.hash);
|
||||
delete(block.previous_block_hash);
|
||||
delete(block.pool_name);
|
||||
@@ -800,6 +802,16 @@ class Blocks {
|
||||
delete(block.pool_regexes);
|
||||
delete(block.median_timestamp);
|
||||
|
||||
// This requires `blocks_summaries` to be available. It takes a very long
|
||||
// time to index this table so we just try to serve the data the best we can
|
||||
if (block.fee_percentiles === null) {
|
||||
block.fee_percentiles = await BlocksSummariesRepository.$getFeePercentilesByBlockId(block.id);
|
||||
if (block.fee_percentiles !== null) {
|
||||
block.median_fee_amt = block.fee_percentiles[3];
|
||||
await blocksRepository.$saveFeePercentilesForBlockId(block.id, block.fee_percentiles);
|
||||
}
|
||||
}
|
||||
|
||||
blocks.push(block);
|
||||
fromHeight++;
|
||||
}
|
||||
|
||||
@@ -772,7 +772,7 @@ class DatabaseMigration {
|
||||
ADD total_outputs int unsigned NOT NULL,
|
||||
ADD total_output_amt bigint unsigned NOT NULL,
|
||||
ADD fee_percentiles longtext NULL,
|
||||
ADD median_fee_amt int unsigned NOT NULL,
|
||||
ADD median_fee_amt int unsigned NULL,
|
||||
ADD segwit_total_txs int unsigned NOT NULL,
|
||||
ADD segwit_total_size int unsigned NOT NULL,
|
||||
ADD segwit_total_weight int unsigned NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user