mirror of https://github.com/status-im/nim-eth.git
Add relay notifications WIP
This commit is contained in:
parent
b1a99d5ea3
commit
89903c4524
|
@ -13,7 +13,7 @@
|
|||
|
||||
import
|
||||
std/[hashes, net],
|
||||
./enr
|
||||
"."/[enr, node]
|
||||
|
||||
type
|
||||
MessageKind* = enum
|
||||
|
@ -25,12 +25,16 @@ type
|
|||
unused = 0x00
|
||||
|
||||
# The supported message types
|
||||
# Request & response
|
||||
ping = 0x01
|
||||
pong = 0x02
|
||||
findNode = 0x03
|
||||
nodes = 0x04
|
||||
talkReq = 0x05
|
||||
talkResp = 0x06
|
||||
# Notifications
|
||||
relayInit = 0x07
|
||||
relayMsg = 0x08
|
||||
|
||||
RequestId* = object
|
||||
id*: seq[byte]
|
||||
|
@ -57,9 +61,20 @@ type
|
|||
TalkRespMessage* = object
|
||||
response*: seq[byte]
|
||||
|
||||
RelayInitNotification* = object
|
||||
initiatorEnr*: Record
|
||||
targetId*: NodeId
|
||||
nonce*: array[12, byte] # TODO: is this ok?
|
||||
|
||||
RelayMsgNotification* = object
|
||||
initiatorEnr*: Record
|
||||
nonce*: array[12, byte]
|
||||
|
||||
SomeMessage* = PingMessage or PongMessage or FindNodeMessage or NodesMessage or
|
||||
TalkReqMessage or TalkRespMessage
|
||||
|
||||
SomeNotification* = RelayInitNotification or RelayMsgNotification
|
||||
|
||||
Message* = object
|
||||
reqId*: RequestId
|
||||
case kind*: MessageKind
|
||||
|
|
|
@ -106,6 +106,8 @@ func decodeMessage*(body: openArray[byte]): Result[Message, cstring] =
|
|||
of nodes: rlp.decode(message.nodes)
|
||||
of talkReq: rlp.decode(message.talkReq)
|
||||
of talkResp: rlp.decode(message.talkResp)
|
||||
of relayInit: return err("To implement")
|
||||
of relayMsg: return err("To implement")
|
||||
except RlpError, ValueError:
|
||||
return err("Invalid message encoding")
|
||||
|
||||
|
|
Loading…
Reference in New Issue