View Source Xander.Messages (Xander v0.2.0)

This module builds protocol messages ready to be sent to the server.

Summary

Functions

Builds a static query to get the current block height.

Builds a static query to get the current era.

Builds a static query to get the current tip of the chain

Builds a static query to get the current epoch number.

Acquires a snapshot of the mempool, allowing the protocol to make queries.

Releases the current snapshot of the mempool, allowing the protocol to return to the idle state.

Functions

get_current_block_height()

@spec get_current_block_height() :: binary()

Builds a static query to get the current block height.

Payload CBOR: [3, [2]] Payload Bitstring: <<130, 3, 129, 2>>

Examples

iex> <<_timestamp::32, msg::binary>> = Xander.Messages.get_current_block_height() iex> msg <<0, 7, 0, 4, 130, 3, 129, 2>>

get_current_era()

@spec get_current_era() :: binary()

Builds a static query to get the current era.

Payload CBOR: [3, [0, [2, [1]]]] Payload Bitstring: <<130, 3, 130, 0, 130, 2, 129, 1>>

Examples

iex> <<_timestamp::32, msg::binary>> = Xander.Messages.get_current_era() iex> msg <<0, 7, 0, 8, 130, 3, 130, 0, 130, 2, 129, 1>>

get_current_tip()

@spec get_current_tip() :: binary()

Builds a static query to get the current tip of the chain

Payload CBOR: [3] Payload Bitstring: <<129, 3>>

Examples

iex> <<_timestamp::32, msg::binary>> = Xander.Messages.get_current_tip() iex> msg <<0, 7, 0, 4, 130, 3, 129, 3>>

get_epoch_number()

Builds a static query to get the current epoch number.

Payload CBOR: [3, [0, [0, [6, [1]]]]] Payload Bitstring: <<130, 3, 130, 0, 130, 0, 130, 6, 129, 1>>

Examples

iex> <<_timestamp::32, msg::binary>> = Xander.Messages.get_epoch_number() iex> msg <<0, 7, 0, 10, 130, 3, 130, 0, 130, 0, 130, 6, 129, 1>>

msg_acquire()

Acquires a snapshot of the mempool, allowing the protocol to make queries.

Examples

iex> <<_timestamp::32, msg::binary>> = Xander.Messages.msg_acquire()
iex> msg
<<0, 7, 0, 2, 129, 8>>

msg_release()

Releases the current snapshot of the mempool, allowing the protocol to return to the idle state.

Examples

iex> <<_timestamp::32, msg::binary>> = Xander.Messages.msg_release()
iex> msg
<<0, 7, 0, 2, 129, 5>>

transaction(tx_hex)

@spec transaction(binary()) :: binary()