ex_wire v0.1.1 ExWire.Message.Pong
A wrapper for ExWire’s Pong message.
Link to this section Summary
Functions
Decodes a given message binary, which is assumed to be an RLP encoded list of elements
Given a Pong message, encodes it so it can be sent on the wire in RLPx
Pong messages should be routed to given endpoint
Link to this section Types
Link to this type
t()
t() :: %ExWire.Message.Pong{hash: binary, timestamp: integer, to: ExWire.Struct.Endpoint.t}
Link to this section Functions
Decodes a given message binary, which is assumed to be an RLP encoded list of elements.
Examples
iex> ExWire.Message.Pong.decode([[<<1,2,3,4>>, <<>>, <<0, 5>>], <<2>>, 3] |> ExRLP.encode)
%ExWire.Message.Pong{
to: %ExWire.Struct.Endpoint{ip: [1, 2, 3, 4], tcp_port: 5, udp_port: nil},
hash: <<2>>,
timestamp: 3,
}
iex> ExWire.Message.Pong.decode([<<1>>] |> ExRLP.encode)
** (MatchError) no match of right hand side value: [<<1>>]
Given a Pong message, encodes it so it can be sent on the wire in RLPx.
Examples
iex> ExWire.Message.Pong.encode(%ExWire.Message.Pong{
...> to: %ExWire.Struct.Endpoint{ip: [1, 2, 3, 4], tcp_port: 5, udp_port: nil},
...> hash: <<2>>,
...> timestamp: 3}
...> ) |> ExRLP.decode()
[[<<1, 2, 3, 4>>, "", <<0, 5>>], <<2>>, <<3>>]
Pong messages should be routed to given endpoint.
Examples
iex> ExWire.Message.Pong.to(%ExWire.Message.Pong{
...> to: %ExWire.Struct.Endpoint{ip: [1, 2, 3, 4], tcp_port: 5, udp_port: nil},
...> hash: <<2>>,
...> timestamp: 3}
...> )
%ExWire.Struct.Endpoint{ip: [1, 2, 3, 4], tcp_port: 5, udp_port: nil}