View Source Xander.Transaction (Xander v0.2.0)

Submits transactions to a Cardano node using the Node-to-Client (n2c) protocol.

Summary

Types

t()

Type defining the Transaction struct.

Functions

Returns a child specification for the process. This determines the configuration of the OTP process when it is started by its parent.

Emits events when in the connected state. Must transition to the idle state prior to sending queries to the node.

Emits events when in the disconnected state.

Emits events when in the idle state. This maps to the StIdle state in the Cardano Local State Query protocol. This is the state where the process waits for a query to be made and the queue is empty.

Sends a transaction to the connected Cardano node.

Starts a new transaction process.

Types

t()

@type t() :: %Xander.Transaction{
  client: atom(),
  network: any(),
  path: any(),
  port: non_neg_integer() | 0,
  queue: :queue.queue(),
  socket: any()
}

Type defining the Transaction struct.

tx_id()

@type tx_id() :: binary()

Functions

busy(arg1, arg2, data)

@spec busy(
  :info | :internal | {:call, any()},
  {:request, atom(), atom()} | {:tcp_closed, any()},
  t()
) ::
  {:next_state, :disconnected, t()}
  | {:next_state, :disconnected | :idle, t(),
     [{:reply, any(), {:error | :ok, any()}}]}
  | {:keep_state, t(), [{:next_event, :internal, :send_tx}]}

child_spec(opts)

@spec child_spec(Keyword.t()) :: %{
  id: atom(),
  start: {atom(), atom(), Keyword.t()},
  type: atom(),
  restart: atom(),
  shutdown: integer()
}

Returns a child specification for the process. This determines the configuration of the OTP process when it is started by its parent.

connected(atom1, atom2, data)

@spec connected(:info | :internal, :establish | any(), t()) ::
  {:next_state, :disconnected, t()} | {:next_state, :idle, t()}

Emits events when in the connected state. Must transition to the idle state prior to sending queries to the node.

disconnected(arg1, arg2, data)

@spec disconnected(:info | :internal | {:call, any()}, any(), t()) ::
  {:next_state, :disconnected, t()}
  | {:next_state, :connected, t(), [{:next_event, :internal, :establish}]}
  | {:keep_state, t(), [{:reply, any(), {:error, :disconnected}}]}

Emits events when in the disconnected state.

idle(arg1, arg2, data)

@spec idle(
  :info | :internal | {:call, any()},
  {:request, atom(), atom()} | {:tcp_closed, any()},
  t()
) ::
  {:next_state, :disconnected, t()}
  | {:next_state, :busy, t(), [{:next_event, :internal, :send_tx}]}

Emits events when in the idle state. This maps to the StIdle state in the Cardano Local State Query protocol. This is the state where the process waits for a query to be made and the queue is empty.

send(pid \\ __MODULE__, tx_hash)

@spec send(atom() | pid(), binary()) ::
  {:accepted, tx_id()} | {:rejected, binary()} | {:error, binary()}

Sends a transaction to the connected Cardano node.

For example:

Xander.Transaction.send(tx_hash)

start_link(list)

@spec start_link(Keyword.t()) :: GenServer.on_start()

Starts a new transaction process.