diff --git a/fluffy/network/history/history_network.nim b/fluffy/network/history/history_network.nim index 0774b3bda..1b29fb7b7 100644 --- a/fluffy/network/history/history_network.nim +++ b/fluffy/network/history/history_network.nim @@ -41,11 +41,11 @@ proc getContent*(n: HistoryNetwork, key: ContentKey): # When content is found and is in the radius range, store it. if content.isSome() and contentInRange: - n.contentDB.put(contentId, content.get().asSeq()) + n.contentDB.put(contentId, content.get()) # TODO: for now returning bytes, ultimately it would be nice to return proper # domain types. - return content.map(x => x.asSeq()) + return content proc new*( T: type HistoryNetwork, diff --git a/fluffy/network/state/state_network.nim b/fluffy/network/state/state_network.nim index 620289984..c1e396f50 100644 --- a/fluffy/network/state/state_network.nim +++ b/fluffy/network/state/state_network.nim @@ -41,11 +41,11 @@ proc getContent*(n: StateNetwork, key: ContentKey): # When content is found on the network and is in the radius range, store it. if content.isSome() and contentInRange: - n.contentDB.put(contentId, content.get().asSeq()) + n.contentDB.put(contentId, content.get()) # TODO: for now returning bytes, ultimately it would be nice to return proper # domain types. - return content.map(x => x.asSeq()) + return content proc new*( T: type StateNetwork, diff --git a/fluffy/network/wire/portal_protocol.nim b/fluffy/network/wire/portal_protocol.nim index 20e01e584..a31f04558 100644 --- a/fluffy/network/wire/portal_protocol.nim +++ b/fluffy/network/wire/portal_protocol.nim @@ -66,7 +66,7 @@ type FoundContent* = object case kind*: FoundContentKind of Content: - content*: ByteList + content*: seq[byte] of Nodes: nodes*: seq[Node] @@ -149,7 +149,7 @@ proc handleFindContent( encodeMessage(ContentMessage( contentMessageType: contentType, content: ByteList(content))) else: - let connectionId = p.stream.addContentRequest(srcId, ByteList(content)) + let connectionId = p.stream.addContentRequest(srcId, content) encodeMessage(ContentMessage( contentMessageType: connectionIdType, connectionId: connectionId)) @@ -392,12 +392,12 @@ proc findContent*(p: PortalProtocol, dst: Node, contentKey: ByteList): if await readData.withTimeout(p.stream.readTimeout): let content = readData.read await socket.destroyWait() - return ok(FoundContent(kind: Content, content: ByteList.init(content))) + return ok(FoundContent(kind: Content, content: content)) else: socket.close() return err("Reading data from socket timed out, content request failed") of contentType: - return ok(FoundContent(kind: Content, content: m.content)) + return ok(FoundContent(kind: Content, content: m.content.asSeq())) of enrsType: let records = recordsFromBytes(m.enrs) if records.isOk(): @@ -544,7 +544,7 @@ proc lookup*(p: PortalProtocol, target: NodeId): Future[seq[Node]] {.async.} = # networks will probably be very similar. Extract lookup function to separate module # and make it more generaic proc contentLookup*(p: PortalProtocol, target: ByteList, targetId: UInt256): - Future[Option[ByteList]] {.async.} = + Future[Option[seq[byte]]] {.async.} = ## Perform a lookup for the given target, return the closest n nodes to the ## target. Maximum value for n is `BUCKET_SIZE`. # `closestNodes` holds the k closest nodes to target found, sorted by distance @@ -614,7 +614,7 @@ proc contentLookup*(p: PortalProtocol, target: ByteList, targetId: UInt256): # query? discard - return none[ByteList]() + return none[seq[byte]]() proc query*(p: PortalProtocol, target: NodeId, k = BUCKET_SIZE): Future[seq[Node]] {.async.} = diff --git a/fluffy/network/wire/portal_stream.nim b/fluffy/network/wire/portal_stream.nim index 30c9befcb..2f76cc2de 100644 --- a/fluffy/network/wire/portal_stream.nim +++ b/fluffy/network/wire/portal_stream.nim @@ -27,7 +27,7 @@ type ContentRequest = object connectionId: uint16 nodeId: NodeId - content: ByteList + content: seq[byte] timeout: Moment ContentOffer = object @@ -74,7 +74,7 @@ proc addContentOffer*( return connectionId proc addContentRequest*( - stream: PortalStream, nodeId: NodeId, content: ByteList): Bytes2 = + stream: PortalStream, nodeId: NodeId, content: seq[byte]): Bytes2 = var connectionId: Bytes2 brHmacDrbgGenerate(stream.rng[], connectionId) @@ -141,7 +141,7 @@ proc registerIncomingSocketCallback( for i, request in stream.contentRequests: if request.connectionId == client.connectionId and request.nodeId == client.remoteAddress.id: - let fut = client.writeAndClose(request.content.asSeq()) + let fut = client.writeAndClose(request.content) stream.contentRequests.del(i) return fut diff --git a/fluffy/rpc/rpc_portal_api.nim b/fluffy/rpc/rpc_portal_api.nim index cfb9a3c71..0b2858de2 100644 --- a/fluffy/rpc/rpc_portal_api.nim +++ b/fluffy/rpc/rpc_portal_api.nim @@ -122,7 +122,7 @@ proc installPortalApiHandlers*( case foundContent.kind: of Content: return ( - some("0x" & foundContent.content.asSeq().toHex()), + some("0x" & foundContent.content.toHex()), none(seq[Record])) of Nodes: return (