View Source Xogmios.ChainSync behaviour (xogmios v0.1.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

Link to this callback

handle_block(block, state)

View Source
@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.

@callback handle_connect(state) :: {:ok, new_state} when state: term(), new_state: term()

Invoked upon connecting to the server. This callback is optional.

Link to this callback

handle_disconnect(reason, state)

View Source
@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

Link to this function

start_link(client, opts)

View Source
@spec start_link(module(), start_options :: Keyword.t()) ::
  {:ok, pid()} | {:error, term()}

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