ex_wire v0.1.1 ExWire.Handler behaviour
Defines a behavior for all message handlers of RLPx messages.
Message handlers tell us how we should respond to a given incoming transmission, after it has been decoded.
Link to this section Summary
Functions
Decides which module to route the given message to,
or returns :not_implemented if we have no implemented
a handler for the message type
Link to this section Types
Link to this type
handler_response()
handler_response :: :not_implented | :no_response | ExWire.Message.t
Link to this section Functions
Link to this function
dispatch(type, params)
dispatch(integer, ExWire.Handler.Params.t) :: handler_response
Decides which module to route the given message to,
or returns :not_implemented if we have no implemented
a handler for the message type.
Examples
iex> ExWire.Handler.dispatch(0x01, %ExWire.Handler.Params{
...> remote_host: %ExWire.Struct.Endpoint{ip: [1,2,3,4], udp_port: 55},
...> signature: 2,
...> recovery_id: 3,
...> hash: <<5>>,
...> data: [1, [<<1,2,3,4>>, <<>>, <<5>>], [<<5,6,7,8>>, <<6>>, <<>>], 4] |> ExRLP.encode(),
...> timestamp: 123,
...> })
%ExWire.Message.Pong{
hash: <<5>>,
timestamp: 123,
to: %ExWire.Struct.Endpoint{
ip: [1, 2, 3, 4],
tcp_port: 5,
udp_port: nil
}
}
iex> ExWire.Handler.dispatch(0x99, %ExWire.Handler.Params{})
:not_implemented
# TODO: Add a `no_response` test case