mirror of https://github.com/status-im/nim-eth.git
Make msgId fixed int32
This commit is contained in:
parent
5850186ca0
commit
98be627bcc
|
@ -429,8 +429,9 @@ proc recvMsg*(peer: Peer): Future[tuple[msgId: int, msgData: Rlp]] {.async.} =
|
|||
var rlp = rlpFromBytes(decryptedBytes.toRange)
|
||||
|
||||
try:
|
||||
let msgid = rlp.read(int)
|
||||
return (msgId, rlp)
|
||||
# int32 as this seems more than big enough for the amount of msgIds
|
||||
let msgId = rlp.read(int32)
|
||||
return (msgId.int, rlp)
|
||||
except RlpError:
|
||||
await peer.disconnectAndRaise(BreachOfProtocol,
|
||||
"Cannot read RLPx message id")
|
||||
|
|
|
@ -46,5 +46,5 @@ template sourceDir*: string = currentSourcePath.rsplit(DirSep, 1)[0]
|
|||
proc recvMsgMock*(msg: openArray[byte]): tuple[msgId: int, msgData: Rlp] =
|
||||
var rlp = rlpFromBytes(@msg.toRange)
|
||||
|
||||
let msgid = rlp.read(int)
|
||||
return (msgId, rlp)
|
||||
let msgId = rlp.read(int32)
|
||||
return (msgId.int, rlp)
|
|
@ -9,8 +9,13 @@
|
|||
"error": "UnsupportedMessageError",
|
||||
"description": "This is a message id not used by devp2p, eth or whisper"
|
||||
},
|
||||
"Message id that is negative": {
|
||||
"Message id that is bigger than int32": {
|
||||
"payload": "888888888888888888",
|
||||
"error": "RlpTypeMismatch",
|
||||
"description": "This payload will result in too large int for a message id"
|
||||
},
|
||||
"Message id that is negative": {
|
||||
"payload": "8488888888",
|
||||
"error": "UnsupportedMessageError",
|
||||
"description": "This payload will result in a negative number as message id"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue