Anoma.Node.Transaction.Mempool (Anoma v0.29.0)
I am the Mempool Engine.
I posess the core functionality to submit new transactions, execute incoming consensus, and dump current transactions. Alongside that, I store all currently running transactions as well as their intermediate VM results.
As the main point of user-input, I also send the events needed for replays.
All transactions are assumed to come in the form of {backend, noun}.
All consensus is assumed to come in a form of an orered list of binaries.
Public API
I provide the following public functionality:
Summary
Types
I am the type of the Mempool Engine.
I am the type of the transaction result.
I am the type of the Nock VM result.
Functions
Returns a specification to start this module under a supervisor.
I am the execution function.
I am a filter spec which filters for Mempool-related messages.
I am the initialization function for the Mempool Engine.
I am the start_link function for the Mempool Engine.
I am a launch function for a new transaction.
I am a launch function for a new transaction with a given ID.
I am a function to dump transactions.
I am a filter spec which filters for messages from the Backends module.
Types
@type t() :: %Anoma.Node.Transaction.Mempool{ node_id: String.t() | nil, round: non_neg_integer(), transactions: %{required(binary()) => Anoma.Node.Transaction.Mempool.Tx.t()} }
I am the type of the Mempool Engine.
I contain the core information for the mempool functionality, storing the node ID for which the Mempool is launched, a map of transactions with their IDs, as well as the most recent block round.
Fields
:node_id
- The ID of the Node to which a Mempool instantiation isis bound.
:transactions
- A map with keys being the binary IDs of launchedtransactions and values the corresponding transaction data. See `Tx.t()` Default: %{}
:round
- The round of the next block to be created.Default: 0
tx_result()
@type tx_result() :: {:ok, any()} | :error | :in_progress
I am the type of the transaction result.
vm_result()
@type vm_result() :: {:ok, Noun.t()} | :error | :in_progress
I am the type of the Nock VM result.
Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
execute(node_id, ordered_list_of_txs)
I am the execution function.
I receive a list of binaries, which I recognize as a partial order for block execution, sending an appropriate consensus submission event.
Once launched, I send the list to the Executor.
I am asynchronous, meaning that I do not block and blocks can be submitted before the last one got executed.
If execution is susccesful, the Mempool will handle an appropriate message from the Executor, which will trigger block-creation.
filter_for_mempool()
@spec filter_for_mempool() :: Anoma.Node.Transaction.Backends.ForMempoolFilter.t()
I am a filter spec which filters for Mempool-related messages.
init(args)
@spec init([startup_options()]) :: {:ok, t()}
I am the initialization function for the Mempool Engine.
I assume that my arguments come with keywords specifying the node id, alongside transactions, pending orders, and a block round.
If any transactions are provided upon startup, I ask the Mempool to execute them with a particular ID.
If any orders are provided, I also launch them afterwards in the order specified.
Afterwards, I initialize the Mempool with round and node ID specified.
start_link(args \\ [])
@spec start_link([startup_options()]) :: GenServer.on_start()
I am the start_link function for the Mempool Engine.
I register the mempool with supplied node ID provided by the arguments.
tx(node_id, tx_w_backend)
@spec tx( String.t(), {Anoma.Node.Transaction.Backends.backend(), Noun.t()} ) :: :ok
I am a launch function for a new transaction.
Given a node ID with a {backend, tx} tuple, I launch a new transaction with a random ID, sending an appropriate event.
Afterwards, the transaction code is sent to the Executor Engine to be
assigned to a Worder, while the code wrapped in Tx.t()
will be stored
in Mempool's state.
See tx/3
for launching a transaction with a given ID.
tx(node_id, tx_w_backend, id)
@spec tx(String.t(), {Anoma.Node.Transaction.Backends.backend(), Noun.t()}, binary()) :: :ok
I am a launch function for a new transaction with a given ID.
See tx/2
for logic documentation. In constrast to it, I launch an new
transaction with a particular given ID. This functionality is to be used
only for replays and testing.
tx_dump(node_id)
@spec tx_dump(String.t()) :: [Anoma.Node.Transaction.Mempool.Tx.t()]
I am a function to dump transactions.
Given a node ID, I give all the transactions as currently stored in the corresponding Mempool state.
worker_module_filter()
@spec worker_module_filter() :: EventBroker.Filters.SourceModule.t()
I am a filter spec which filters for messages from the Backends module.