Fix median timestamp field - Fix reponse format when block is indexed on the fly

This commit is contained in:
nymkappa 2023-02-18 08:42:38 +09:00
parent 8612dd2d73
commit 8f716a1d8c
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 8 additions and 2 deletions

View File

@ -170,6 +170,7 @@ class Blocks {
blk.extras.coinbaseTx = transactionUtils.stripCoinbaseTransaction(transactions[0]); blk.extras.coinbaseTx = transactionUtils.stripCoinbaseTransaction(transactions[0]);
blk.extras.coinbaseRaw = blk.extras.coinbaseTx.vin[0].scriptsig; blk.extras.coinbaseRaw = blk.extras.coinbaseTx.vin[0].scriptsig;
blk.extras.usd = priceUpdater.latestPrices.USD; blk.extras.usd = priceUpdater.latestPrices.USD;
blk.extras.medianTimestamp = block.medianTime;
if (block.height === 0) { if (block.height === 0) {
blk.extras.medianFee = 0; // 50th percentiles blk.extras.medianFee = 0; // 50th percentiles
@ -204,7 +205,6 @@ class Blocks {
blk.extras.feePercentiles = [], // TODO blk.extras.feePercentiles = [], // TODO
blk.extras.medianFeeAmt = 0; // TODO blk.extras.medianFeeAmt = 0; // TODO
blk.extras.medianTimestamp = block.medianTime; // TODO
blk.extras.blockTime = 0; // TODO blk.extras.blockTime = 0; // TODO
blk.extras.orphaned = false; // TODO blk.extras.orphaned = false; // TODO
@ -785,7 +785,11 @@ class Blocks {
while (fromHeight <= toHeight) { while (fromHeight <= toHeight) {
let block: any = await blocksRepository.$getBlockByHeight(fromHeight); let block: any = await blocksRepository.$getBlockByHeight(fromHeight);
if (!block) { if (!block) {
block = await this.$indexBlock(fromHeight); await this.$indexBlock(fromHeight);
block = await blocksRepository.$getBlockByHeight(fromHeight);
if (!block) {
continue;
}
} }
delete(block.hash); delete(block.hash);
@ -794,6 +798,7 @@ class Blocks {
delete(block.pool_link); delete(block.pool_link);
delete(block.pool_addresses); delete(block.pool_addresses);
delete(block.pool_regexes); delete(block.pool_regexes);
delete(block.median_timestamp);
blocks.push(block); blocks.push(block);
fromHeight++; fromHeight++;

View File

@ -367,6 +367,7 @@ class BlocksRepository {
blocks.*, blocks.*,
hash as id, hash as id,
UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
UNIX_TIMESTAMP(blocks.median_timestamp) as medianTime,
pools.id as pool_id, pools.id as pool_id,
pools.name as pool_name, pools.name as pool_name,
pools.link as pool_link, pools.link as pool_link,