ex_wire v0.1.1 ExWire.Message.FindNeighbours

A wrapper for ExWire’s FindNeighbours message.

“Id of a node. The responding node will send back nodes closest to the target.”

Link to this section Summary

Functions

Decodes a given message binary, which is assumed to be an RLP encoded list of elements

Given a FindNeighbours message, encodes it so it can be sent on the wire in RLPx

Callback implementation for ExWire.Message.message_id/0

FindNeighbours messages do not specify a destination

Link to this section Types

Link to this type t()
t() :: %ExWire.Message.FindNeighbours{target: ExWire.node_id, timestamp: integer}

Link to this section Functions

Link to this function decode(data)
decode(binary) :: t

Decodes a given message binary, which is assumed to be an RLP encoded list of elements.

Examples

iex> ExWire.Message.FindNeighbours.decode([<<1>>, 2] |> ExRLP.encode)
%ExWire.Message.FindNeighbours{
  target: <<1>>,
  timestamp: 2,
}

iex> ExWire.Message.FindNeighbours.decode([<<1>>] |> ExRLP.encode)
** (MatchError) no match of right hand side value: [<<1>>]
Link to this function encode(find_neighbours)
encode(t) :: binary

Given a FindNeighbours message, encodes it so it can be sent on the wire in RLPx.

Examples

iex> ExWire.Message.FindNeighbours.encode(%ExWire.Message.FindNeighbours{target: <<1>>, timestamp: 2})
...> |> ExRLP.decode()
[<<1>>, <<2>>]

Callback implementation for ExWire.Message.message_id/0.

Link to this function to(message)
to(t) :: Endpoint.t | nil

FindNeighbours messages do not specify a destination.

Examples

iex> ExWire.Message.FindNeighbours.to(%ExWire.Message.FindNeighbours{target: <<1>>, timestamp: 2})
nil