Skip to main content

scan_pending_blocks

Function scan_pending_blocks 

Source
async fn scan_pending_blocks(
    btc_rpc: &ServerBitcoinRpcMonitor,
    pks_hash: &Hash,
    block_count: u64,
    cache: &mut BTreeMap<u64, (BlockHash, Vec<PendingOutput>)>,
) -> Result<()>
Expand description

Collects the receive outputs of the most recently mined blocks.

Scans the last MAX_PENDING_DEPTH blocks below the guardian’s local chain tip. The window is relative to the tip rather than to the consensus block count, so the work stays bounded even if the federation’s consensus block count is lagging badly, and so a peg-in keeps being reported for a while after it becomes final.

Blocks are only fetched when the hash at a height is absent from cache or differs from the cached one, which keeps the steady state cost at one block fetch per new block and makes reorgs within the window self-repairing.