ex_wire v0.1.1 ExWire.Struct.Neighbour
Struct to represent an neighbour in RLPx.
Link to this section Summary
Functions
Returns a struct given an ip in binary form, plus an
udp_port or tcp_port, along with a node_id, returns
a Neighbour struct
Versus encode/4, and given a module with an ip, a tcp_port, a udp_port,
and a node_id, returns a tuple of encoded values
Link to this section Types
Link to this type
t()
t() :: %ExWire.Struct.Neighbour{endpoint: ExWire.Struct.Endpoint.t, node: ExWire.node_id}
Link to this section Functions
Returns a struct given an ip in binary form, plus an
udp_port or tcp_port, along with a node_id, returns
a Neighbour struct.
Examples
iex> ExWire.Struct.Neighbour.decode([<<1,2,3,4>>, <<>>, <<5>>, <<7, 7>>])
%ExWire.Struct.Neighbour{
endpoint: %ExWire.Struct.Endpoint{
ip: [1,2,3,4],
udp_port: nil,
tcp_port: 5,
},
node: <<7, 7>>
}
Versus encode/4, and given a module with an ip, a tcp_port, a udp_port,
and a node_id, returns a tuple of encoded values.
Examples
iex> ExWire.Struct.Neighbour.encode(
...> %ExWire.Struct.Neighbour{
...> endpoint: %ExWire.Struct.Endpoint{
...> ip: [1, 2, 3, 4],
...> udp_port: nil,
...> tcp_port: 5,
...> },
...> node: <<7, 8>>,
...> }
...> )
[<<1, 2, 3, 4>>, <<>>, <<0, 5>>, <<7, 8>>]