Function fetch_new_blocks

Source
async fn fetch_new_blocks(
    db: &Database,
    rpc: &ExtendedBitcoinRpc,
    current_height: u32,
    finality_depth: u32,
) -> Result<Option<Vec<BlockInfo>>, BridgeError>
Expand description

Fetches the next block from Bitcoin, if it exists. Will also fetch previous blocks if the parent is missing, and give an error if the number of reorged blocks is greater than the finality depth.

§Parameters

  • current_height: The height of the current tip in the database.

§Returns

  • None - If no new block is available.
  • Vec<BlockInfo> - If new blocks are found.
  • BridgeError - If the number of reorged blocks is greater than the finality depth or db/rpc errors.