aztec_pxe/sync/block_sync.rs
1//! Block header synchronization with the Aztec node.
2
3use aztec_core::error::Error;
4use aztec_node_client::AztecNode;
5
6/// Synchronizes the local block header with the node.
7pub struct BlockSynchronizer;
8
9impl BlockSynchronizer {
10 /// Fetch the latest block header from the node.
11 pub async fn sync_block_header<N: AztecNode>(node: &N) -> Result<serde_json::Value, Error> {
12 // block_number 0 = latest
13 node.get_block_header(0).await
14 }
15
16 /// Fetch a specific block header by number.
17 pub async fn get_block_header<N: AztecNode>(
18 node: &N,
19 block_number: u64,
20 ) -> Result<serde_json::Value, Error> {
21 node.get_block_header(block_number).await
22 }
23}