Reduce compiler warnings related to rlp encode int (#699)

This commit is contained in:
andri lim 2024-06-12 09:29:18 +07:00 committed by GitHub
parent 9b6497ed8a
commit 4cccf25af7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View File

@ -52,7 +52,7 @@ proc append*(w: var RlpWriter, a: IpAddress) =
of IpAddressFamily.IPv4: of IpAddressFamily.IPv4:
w.append(a.address_v4) w.append(a.address_v4)
proc append(w: var RlpWriter, p: Port) = w.append(p.int) proc append(w: var RlpWriter, p: Port) = w.append(p.uint)
proc append(w: var RlpWriter, pk: PublicKey) = w.append(pk.toRaw()) proc append(w: var RlpWriter, pk: PublicKey) = w.append(pk.toRaw())
proc append(w: var RlpWriter, h: MDigest[256]) = w.append(h.data) proc append(w: var RlpWriter, h: MDigest[256]) = w.append(h.data)
@ -114,7 +114,7 @@ proc send(d: DiscoveryProtocol, n: Node, data: seq[byte]) =
f.addCallback cb f.addCallback cb
proc sendPing*(d: DiscoveryProtocol, n: Node): seq[byte] = proc sendPing*(d: DiscoveryProtocol, n: Node): seq[byte] =
let payload = rlp.encode((PROTO_VERSION, d.address, n.node.address, let payload = rlp.encode((PROTO_VERSION.uint, d.address, n.node.address,
expiration())) expiration()))
let msg = pack(cmdPing, payload, d.privKey) let msg = pack(cmdPing, payload, d.privKey)
result = msg[0 ..< MAC_SIZE] result = msg[0 ..< MAC_SIZE]

View File

@ -1000,7 +1000,7 @@ proc p2pProtocolBackendImpl*(protocol: P2PProtocol): Backend =
var `rlpWriter` = `initRlpWriter`() var `rlpWriter` = `initRlpWriter`()
const `perProtocolMsgIdVar` {.used.} = `msgId` const `perProtocolMsgIdVar` {.used.} = `msgId`
let `perPeerMsgIdVar` = `perPeerMsgIdValue` let `perPeerMsgIdVar` = `perPeerMsgIdValue`
`append`(`rlpWriter`, `perPeerMsgIdVar`) `append`(`rlpWriter`, `perPeerMsgIdVar`.uint)
when tracingEnabled: when tracingEnabled:
appendParams.add logSentMsgFields(peerVar, protocol, msgId, paramsToWrite) appendParams.add logSentMsgFields(peerVar, protocol, msgId, paramsToWrite)
@ -1032,6 +1032,7 @@ proc p2pProtocolBackendImpl*(protocol: P2PProtocol): Backend =
newLit(protocol.version), newLit(protocol.version),
protocol.peerInit, protocol.netInit) protocol.peerInit, protocol.netInit)
p2pProtocol DevP2P(version = 5, rlpxName = "p2p"): p2pProtocol DevP2P(version = 5, rlpxName = "p2p"):
proc hello(peer: Peer, proc hello(peer: Peer,
version: uint, version: uint,

View File

@ -460,7 +460,7 @@ proc mergeAndGraft(self: var HexaryTrie;
output.append hexPrefixEncode(NibblesSeq(), true) output.append hexPrefixEncode(NibblesSeq(), true)
else: else:
doAssert(not soleChild.isEmpty) doAssert(not soleChild.isEmpty)
output.append int(hexPrefixEncodeByte(childPos)) output.append uint(hexPrefixEncodeByte(childPos))
output.append(soleChild) output.append(soleChild)
result = output.finish() result = output.finish()