diff --git a/eth/p2p/discoveryv5/encoding.nim b/eth/p2p/discoveryv5/encoding.nim index 0f4e2e6..6ca8a51 100644 --- a/eth/p2p/discoveryv5/encoding.nim +++ b/eth/p2p/discoveryv5/encoding.nim @@ -236,7 +236,7 @@ proc encodeWhoareyouPacket*(rng: var BrHmacDrbgContext, c: var Codec, # authdata var authdata: seq[byte] authdata.add(idNonce) - authdata.add(recordSeq.tobytesBE) + authdata.add(recordSeq.toBytesBE) # static-header let staticHeader = encodeStaticHeader(Flag.Whoareyou, requestNonce, diff --git a/eth/p2p/discoveryv5/node.nim b/eth/p2p/discoveryv5/node.nim index d5c1f07..d1ce2df 100644 --- a/eth/p2p/discoveryv5/node.nim +++ b/eth/p2p/discoveryv5/node.nim @@ -88,9 +88,6 @@ proc random*(T: type NodeId, rng: var BrHmacDrbgContext): T = id -func toBytes*(id: NodeId): array[32, byte] = - id.toByteArrayBE() - func `$`*(id: NodeId): string = id.toHex() diff --git a/eth/p2p/discoveryv5/routing_table.nim b/eth/p2p/discoveryv5/routing_table.nim index a957a74..fc7354c 100644 --- a/eth/p2p/discoveryv5/routing_table.nim +++ b/eth/p2p/discoveryv5/routing_table.nim @@ -104,10 +104,10 @@ func logDistance*(a, b: NodeId): uint16 = ## is rather the log base 2 of the distance + 1, as else the 0 value can not ## be used (e.g. by FindNode call to return peer its own ENR) ## For NodeId of 256 bits, range is 0-256. - let a = a.toBytes - let b = b.toBytes + let a = a.toBytesBE + let b = b.toBytesBE var lz = 0 - for i in countdown(a.len - 1, 0): + for i in 0..