View Source Xander.ChainSync behaviour (Xander v0.3.0)

Summary

Callbacks

Invoked when a new block is emitted. This callback is required.

Invoked when a rollback event is emitted. This callback is optional.

Callbacks

handle_block(block, state)

@callback handle_block(block :: map(), state) ::
  {:ok, :next_block, new_state} | {:close, new_state}
when state: term(), new_state: term()

Invoked when a new block is emitted. This callback is required.

Receives block information as argument and the current state of the handler.

Returning {:ok, :next_block, new_state} will request the next block once it's made available.

Returning {:close, new_state} will close the connection to the node.

handle_rollback(point, state)

@callback handle_rollback(point :: map(), state) :: {:ok, :next_block, new_state}
when state: term(), new_state: term()

Invoked when a rollback event is emitted. This callback is optional.

Receives as argument a point and the state of the handler. The point is a map with keys for id (block id) and a slot. This information can then be used by the handler module to perform the necessary corrections. For example, resetting all current known state past this point and then rewriting it from future invokations of handle_block/2

Returning {:ok, :next_block, new_state} will request the next block once it's made available. This is the only valid return value.

Functions

catching_up(atom1, atom2, data)

connected(atom1, atom2, data)

disconnected(arg1, arg2, data)

Emits events when in the disconnected state.

new_blocks(atom, arg, module_state)

start_link(client_module, opts)

Starts a new query process.