View Source Xander.Query (Xander v0.2.0)

Issues ledger queries to a Cardano node using the Node-to-Client (n2c) protocol. This module implements the gen_statem OTP behaviour.

Summary

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 established_has_agency state prior to sending queries to the node.

Emits events when in the disconnected state.

Emits events when in the established_has_agency state. This maps to the Querying state in the Cardano Local State Query protocol.

Emits events when in the established_no_agency 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.

Sends a query to the connected Cardano node.

Starts a new query process.

Functions

child_spec(opts)

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

connected(arg1, arg2, data)

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

disconnected(arg1, arg2, data)

Emits events when in the disconnected state.

established_has_agency(arg1, arg2, data)

Emits events when in the established_has_agency state. This maps to the Querying state in the Cardano Local State Query protocol.

established_no_agency(arg1, arg2, data)

Emits events when in the established_no_agency 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.

run(pid \\ __MODULE__, query_name)

@spec run(pid() | atom(), atom()) :: {atom(), any()}

Sends a query to the connected Cardano node.

Available queries are:

  • :get_current_era
  • :get_current_block_height
  • :get_epoch_number
  • :get_current_tip

For example:

Xander.Query.run(pid, :get_epoch_number)

start_link(list)

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

Starts a new query process.