View Source Xogmios.ChainSync behaviour (xogmios v0.3.0)
This module interfaces with the Chain Synchronization protocol.
Summary
Callbacks
Invoked when a new block is emitted. This callback is required.
Invoked upon connecting to the server. This callback is optional.
Invoked upon disconnecting from the server. This callback is optional.
Functions
Starts a new Chain Sync process linked to the current process.
Callbacks
@callback handle_block(block :: map(), state) :: {:ok, :next_block, new_state} | {:ok, new_state} | {:close, new_state} when state: term(), new_state: term()
Invoked when a new block is emitted. This callback is required.
Returning {:ok, :next_block, new_state}
will request the next block once it's made available.
Returning {:ok, new_state}
will not request anymore blocks.
Returning {:ok, :close, new_state}
will close the connection to the server.
Invoked upon connecting to the server. This callback is optional.
@callback handle_disconnect(reason :: String.t(), state) :: {:ok, new_state} | {:reconnect, interval_in_ms :: non_neg_integer(), new_state} when state: term(), new_state: term()
Invoked upon disconnecting from the server. This callback is optional.
Returning {:ok, new_state}
will allow the connection to close.
Returning {:reconnect, interval_in_ms}
will attempt a reconnection after interval_in_ms
Functions
Starts a new Chain Sync process linked to the current process.
This function should not be called directly, but rather via Xogmios.start_chain_sync_link/2