mirror of https://github.com/status-im/nim-eth.git
p2pRequestComplete parameters are not a separate list
This commit is contained in:
parent
48c9adbb6a
commit
4dde3af2d5
|
@ -64,12 +64,12 @@ proc requestMail*(node: EthereumNode, peerId: NodeId, request: MailRequest,
|
|||
# TODO: I guess the idea is to check requestId (Hash) also?
|
||||
let requests = requests - 1
|
||||
# If there is cursor data, do another request
|
||||
if response.data.cursor.len > 0 and requests > 0:
|
||||
if response.cursor.len > 0 and requests > 0:
|
||||
var newRequest = request
|
||||
newRequest.cursor = response.data.cursor
|
||||
newRequest.cursor = response.cursor
|
||||
return await requestMail(node, peerId, newRequest, symKey, requests)
|
||||
else:
|
||||
return some(response.data.cursor)
|
||||
return some(response.cursor)
|
||||
else:
|
||||
error "p2pRequestComplete timeout"
|
||||
return result
|
||||
|
|
|
@ -114,17 +114,6 @@ type
|
|||
config*: WakuConfig
|
||||
p2pRequestHandler*: P2PRequestHandler
|
||||
|
||||
# TODO: In the current specification this is not wrapped in a regular envelope
|
||||
# as is done for the P2P Request packet. If we could alter this in the spec it
|
||||
# would be a cleaner separation between Waku and Mail server / client and then
|
||||
# this could be moved to waku_mail.nim
|
||||
# Also, the requestId could live at layer lower. And the protocol DSL
|
||||
# currently supports this, if used in a requestResponse block.
|
||||
P2PRequestCompleteObject* = object
|
||||
requestId*: Hash
|
||||
lastEnvelopeHash*: Hash
|
||||
cursor*: Bytes
|
||||
|
||||
RateLimits* = object
|
||||
# TODO: uint or specifically uint32?
|
||||
limitIp*: uint
|
||||
|
@ -352,13 +341,21 @@ p2pProtocol Waku(version = wakuVersion,
|
|||
proc p2pSyncRequest(peer: Peer) = discard
|
||||
proc p2pSyncResponse(peer: Peer) = discard
|
||||
|
||||
proc p2pRequestComplete(peer: Peer, data: P2PRequestCompleteObject) = discard
|
||||
# TODO: This is actually rather a requestResponse in combination with
|
||||
# p2pRequest. However, we can't use that system due to the unfortunate fact
|
||||
# that the packet IDs are not consecutive, and nextID is not recognized in
|
||||
# between these. The nextID behaviour could be fixed, however it would be
|
||||
# cleaner if the specification could be changed to have these IDs to be
|
||||
# consecutive.
|
||||
|
||||
proc p2pRequestComplete(peer: Peer, requestId: Hash, lastEnvelopeHash: Hash,
|
||||
cursor: Bytes) = discard
|
||||
# TODO:
|
||||
# In the current specification the parameters are not wrapped in a regular
|
||||
# envelope as is done for the P2P Request packet. If we could alter this in
|
||||
# the spec it would be a cleaner separation between Waku and Mail server /
|
||||
# client.
|
||||
# Also, if a requestResponse block is used, a reqestId will automatically
|
||||
# be added by the protocol DSL.
|
||||
# However the requestResponse block in combination with p2pRequest cannot be
|
||||
# used due to the unfortunate fact that the packet IDs are not consecutive,
|
||||
# and nextID is not recognized in between these. The nextID behaviour could
|
||||
# be fixed, however it would be cleaner if the specification could be
|
||||
# changed to have these IDs to be consecutive.
|
||||
|
||||
# 'Runner' calls ---------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ suite "Waku Mail Client":
|
|||
output.bloom == bloom
|
||||
output.limit == limit
|
||||
|
||||
var test: P2PRequestCompleteObject
|
||||
await peer.p2pRequestComplete(test)
|
||||
var dummy: Hash
|
||||
await peer.p2pRequestComplete(dummy, dummy, @[])
|
||||
|
||||
check await cursorFut.withTimeout(transmissionTimeout)
|
||||
|
||||
|
@ -93,13 +93,15 @@ suite "Waku Mail Client":
|
|||
var envelopes: seq[Envelope]
|
||||
traceAsyncErrors peer.p2pMessage(envelopes)
|
||||
|
||||
var test: P2PRequestCompleteObject
|
||||
var cursor: Bytes
|
||||
count = count - 1
|
||||
if count == 0:
|
||||
test.cursor = @[]
|
||||
cursor = @[]
|
||||
else:
|
||||
test.cursor = @[byte count]
|
||||
traceAsyncErrors peer.p2pRequestComplete(test)
|
||||
cursor = @[byte count]
|
||||
|
||||
var dummy: Hash
|
||||
traceAsyncErrors peer.p2pRequestComplete(dummy, dummy, cursor)
|
||||
|
||||
simpleServer.enableMailServer(customHandler)
|
||||
check client.setPeerTrusted(simpleServerNode.id)
|
||||
|
|
Loading…
Reference in New Issue