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