pub struct BlockStateSynchronizer { /* private fields */ }Expand description
Block state synchronizer that manages block header tracking and reorg handling.
Matches the TS BlockSynchronizer:
- Syncs the anchor block header from the node
- Detects chain reorganizations (when the node’s block number < our anchor)
- Rolls back NoteStore and PrivateEventStore on reorg
- Signals ContractSyncService cache invalidation
The synchronizer ensures that all PXE state is consistent with the node’s view of the chain.
Implementations§
Source§impl BlockStateSynchronizer
impl BlockStateSynchronizer
pub fn new( anchor_block_store: Arc<AnchorBlockStore>, note_store: Arc<NoteStore>, private_event_store: Arc<PrivateEventStore>, config: BlockSyncConfig, ) -> BlockStateSynchronizer
Sourcepub async fn sync<N>(&self, node: &N) -> Result<(), Error>where
N: AztecNode,
pub async fn sync<N>(&self, node: &N) -> Result<(), Error>where
N: AztecNode,
Sync the PXE with the node’s current state.
This is the main entry point called before transaction simulation or event retrieval. It:
- Fetches the latest block header from the node
- Detects if a reorg has occurred
- Handles rollback if needed
- Updates the anchor block header
Sourcepub async fn take_anchor_changed(&self) -> bool
pub async fn take_anchor_changed(&self) -> bool
Check and consume the anchor-changed flag.
Returns true if the anchor block has changed since the last call.
The flag is reset to false after reading.
This is used by EmbeddedPxe to know when to wipe the ContractSyncService cache.
Sourcepub fn anchor_block_store(&self) -> &AnchorBlockStore
pub fn anchor_block_store(&self) -> &AnchorBlockStore
Get a reference to the anchor block store.
Sourcepub async fn get_anchor_block_header(
&self,
) -> Result<Option<AnchorBlockHeader>, Error>
pub async fn get_anchor_block_header( &self, ) -> Result<Option<AnchorBlockHeader>, Error>
Get the current anchor block header.
Sourcepub async fn get_anchor_block_number(&self) -> Result<u64, Error>
pub async fn get_anchor_block_number(&self) -> Result<u64, Error>
Get the current anchor block number.
Auto Trait Implementations§
impl !Freeze for BlockStateSynchronizer
impl !RefUnwindSafe for BlockStateSynchronizer
impl Send for BlockStateSynchronizer
impl Sync for BlockStateSynchronizer
impl Unpin for BlockStateSynchronizer
impl !UnwindSafe for BlockStateSynchronizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more