View Source Xogmios.MempoolTxs behaviour (xogmios v0.8.0)

This module interfaces with the Mempool protocol for reading transactions as they become available (nextTransaction).

Summary

Callbacks

Invoked when a new snapshot is acquired.

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

Invoked upon disconnecting from the server. This callback is optional.

Invoked when a new transaction is made available in the mempool.

Functions

Starts a new Mempool process linked to the current process.

Callbacks

Link to this callback

handle_acquired(snapshop, state)

View Source
@callback handle_acquired(snapshop :: map(), state) ::
  {:ok, :next_transaction, new_state} | {:ok, new_state} | {:close, new_state}
when state: term(), new_state: term()

Invoked when a new snapshot is acquired.

Receives snapshot information as argument.

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

Returning {:ok, new_state} wil not request anymore transactions.

Returning {: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

Link to this callback

handle_transaction(transaction, state)

View Source
@callback handle_transaction(transaction :: map(), state) ::
  {:ok, :next_transaction, new_state} | {:ok, new_state} | {:close, new_state}
when state: term(), new_state: term()

Invoked when a new transaction is made available in the mempool.

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

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

Returning {:ok, new_state} wil not request anymore transactions.

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

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 Mempool process linked to the current process.

This function should not be called directly, but rather via Xogmios.start_mempool_txs_link/2