Skip to content

Added pending block component. - #648

Open
Randy808 wants to merge 2 commits into
Blockstream:masterfrom
Randy808:pending-block-component
Open

Added pending block component.#648
Randy808 wants to merge 2 commits into
Blockstream:masterfrom
Randy808:pending-block-component

Conversation

@Randy808

@Randy808 Randy808 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

To run locally, npm install and use the following snippets:

# Bitcoin
export API_URL=https://blockstream.info/api
export PORT=4999
source flavors/blockstream/config.env
source flavors/bitcoin-mainnet/config.env
npm run dev-server
# Liquid
export API_URL=https://blockstream.info/liquid/api
export PORT=5000
source flavors/blockstream/config.env
source flavors/liquid-mainnet/config.env
npm run dev-server

@Randy808
Randy808 force-pushed the pending-block-component branch from 3ec7468 to f980da7 Compare July 31, 2026 18:38
@Randy808 Randy808 self-assigned this Jul 31, 2026
@Randy808
Randy808 force-pushed the pending-block-component branch from f980da7 to f4a0a26 Compare August 11, 2026 20:35
@Randy808
Randy808 marked this pull request as ready for review August 11, 2026 20:59
@FedOken
FedOken self-requested a review August 12, 2026 04:35

const ExpandedBlockDetails = ({ block }) => {
const weightPercentage = getBlockPercentageUsed(block.weight);
const sizePercentage = (block.size / maxBlockWeight) * 100;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block.size is bytes, maxBlockWeight is weight units (4,000,000 WU). These aren't the same scale.

Post-SegWit there's no fixed byte-size cap to compare against anyway (size for a max-weight block ranges ~1–4MB depending on witness ratio), so this isn't just a wrong-constant — the metric itself needs a decision.

import { summarizeBlockTemplate } from "../lib/block-template";
import { formatSat, formatVMB } from "./util";

const BLOCK_TARGET_SECONDS = (process.env.IS_ELEMENTS ? 1 : 10) * 60;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have it in const.js

export const targetBlockIntervalSeconds = configuredTargetBlockIntervalSeconds > 0
  ? configuredTargetBlockIntervalSeconds
  : process.env.IS_ELEMENTS ? 60 : 600

: valueFallback,
bucket
? formatFeeCost(bucket.averageFee, bitcoinPrice, costFallback)
: valueFallback,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valueFallback -> costFallback ?

blockTemplate && feeEst && bitcoinMarketChart ? "N/A" : "-";
const totalFeesUsdFallback =
blockTemplate && bitcoinMarketChart ? "N/A" : "-";
const metrics = summarizeBlockTemplate(blockTemplate, feeEst);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summarizeBlockTemplate recomputes on every render, not just when data changes.

It's called unconditionally on every invocation of PendingBlockDetailsCard, which re-renders on every state$, not only when blockTemplate itself updates. Per the polling schedule, mempool/recent refreshes every 5s while block-template refreshes every 30s, so this multi-pass computation over potentially thousands of mempool transactions reruns ~6x more often than the underlying data actually changes.

Comment on lines +344 to +347
const panelTooltip = (text) => ({
iconSrc: `${staticRoot}img/icons/tooltip.svg`,
text,
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as existed detailTooltip

const detailTooltip = (text) => ({
  iconSrc: `${staticRoot}img/icons/tooltip.svg`,
  text,
});

Comment on lines +361 to +368
const bar = ({
className,
title,
headerValue,
fillPercentage,
barFillClass,
footer,
}) => (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost the same as existed detailBar

const formatCount = (value, fallback = "N/A") =>
Number.isFinite(value) ? value.toLocaleString() : fallback;

const formatBitcoin = (sats, fallback = "N/A") =>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use formatSat?

@@ -0,0 +1,1044 @@
const MAX_BLOCK_WEIGHT = 4_000_000;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use maxBlockWeight from const?

@FedOken

FedOken commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

How to test with a working endpoint /block-template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants