Use ByteList.init instead of List 2048 (#876)

This commit is contained in:
Kim De Mey 2021-10-22 17:49:23 +02:00 committed by GitHub
parent 4b498356fc
commit 92dfb02ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 6 deletions

View File

@ -50,7 +50,7 @@ func fromSszBytes*(T: type ContentType, data: openArray[byte]):
contentType contentType
func encode*(contentKey: ContentKey): ByteList = func encode*(contentKey: ContentKey): ByteList =
List.init(SSZ.encode(contentKey), 2048) ByteList.init(SSZ.encode(contentKey))
func decode*(contentKey: ByteList): Option[ContentKey] = func decode*(contentKey: ByteList): Option[ContentKey] =
try: try:

View File

@ -62,7 +62,7 @@ func fromSszBytes*(T: type ContentType, data: openArray[byte]):
contentType contentType
func encode*(contentKey: ContentKey): ByteList = func encode*(contentKey: ContentKey): ByteList =
List.init(SSZ.encode(contentKey), 2048) ByteList.init(SSZ.encode(contentKey))
# TODO consider if more powerfull error handling is necessary here. # TODO consider if more powerfull error handling is necessary here.
func decode*(contentKey: ByteList): Option[ContentKey] = func decode*(contentKey: ByteList): Option[ContentKey] =

View File

@ -111,8 +111,7 @@ suite "Portal Wire Protocol Message Encodings":
test "FindContent Request": test "FindContent Request":
let let
contentEncoded: ByteList = List.init(@[1'u8], 2048) contentEncoded = ByteList.init(@[1'u8])
fn = FindContentMessage(contentKey: contentEncoded) fn = FindContentMessage(contentKey: contentEncoded)
let encoded = encodeMessage(fn) let encoded = encodeMessage(fn)

View File

@ -123,7 +123,7 @@ procSuite "Portal Wire Protocol Tests":
# table. # table.
test.proto2.start() test.proto2.start()
let contentKey = List.init(@[1'u8], 2048) let contentKey = ByteList.init(@[1'u8])
# content does not exist so this should provide us with the closest nodes # content does not exist so this should provide us with the closest nodes
# to the content, which is the only node in the routing table. # to the content, which is the only node in the routing table.

View File

@ -221,7 +221,7 @@ proc run(config: DiscoveryConf) =
key key
# For now just some random bytes # For now just some random bytes
let contentKey = List.init(@[1'u8], 2048) let contentKey = ByteList.init(@[1'u8])
let foundContent = waitFor portal.findContent(config.findContentTarget, let foundContent = waitFor portal.findContent(config.findContentTarget,
contentKey) contentKey)