From 1924bcc96c53aa1e66f6f6f60364af118ab01207 Mon Sep 17 00:00:00 2001 From: Dean Eigenmann <7621705+decanus@users.noreply.github.com> Date: Fri, 28 Aug 2020 13:07:52 +0200 Subject: [PATCH] enhancement/request-id-to-uuid (#113) --- tests/v2/test_waku_store.nim | 6 +++--- waku/protocol/v2/waku_store.nim | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/v2/test_waku_store.nim b/tests/v2/test_waku_store.nim index f09d621e3..42ad2bf4f 100644 --- a/tests/v2/test_waku_store.nim +++ b/tests/v2/test_waku_store.nim @@ -22,7 +22,7 @@ procSuite "Waku Store": peer = PeerInfo.init(PrivateKey.random(ECDSA, rng[]).get()) msg = Message.init(peer, @[byte 1, 2, 3], "topic", 3, false) - rpc = StoreRPC(query: @[HistoryQuery(requestID: 1, topics: @["foo"])], response: @[HistoryResponse(requestID: 1, messages: @[msg])]) + rpc = StoreRPC(query: @[HistoryQuery(uuid: "1", topics: @["foo"])], response: @[HistoryResponse(uuid: "1", messages: @[msg])]) let buf = rpc.encode() @@ -70,7 +70,7 @@ procSuite "Waku Store": let transport2: TcpTransport = TcpTransport.init() let conn = await transport2.dial(transport1.ma) - var rpc = StoreRPC(query: @[HistoryQuery(requestID: 1, topics: @["topic"])]) + var rpc = StoreRPC(query: @[HistoryQuery(uuid: "1234", topics: @["topic"])]) discard await msDial.select(conn, WakuStoreCodec) await conn.writeLP(rpc.encode().buffer) @@ -79,6 +79,6 @@ procSuite "Waku Store": check: response.isErr == false - response.value.response[0].requestID == rpc.query[0].requestID + response.value.response[0].uuid == rpc.query[0].uuid response.value.response[0].messages.len() == 1 response.value.response[0].messages[0] == msg diff --git a/waku/protocol/v2/waku_store.nim b/waku/protocol/v2/waku_store.nim index 7c09186c3..d60f4638c 100644 --- a/waku/protocol/v2/waku_store.nim +++ b/waku/protocol/v2/waku_store.nim @@ -23,11 +23,11 @@ type response*: seq[HistoryResponse] HistoryQuery* = object - requestID*: uint64 + uuid*: string topics*: seq[string] HistoryResponse* = object - requestID*: uint64 + uuid*: string messages*: seq[Message] WakuStore* = ref object of LPProtocol @@ -39,7 +39,7 @@ method init*(T: type HistoryQuery, buffer: seq[byte]): ProtoResult[T] = var topics: seq[string] - discard ? pb.getField(1, msg.requestID) + discard ? pb.getField(1, msg.uuid) discard ? pb.getRepeatedField(2, topics) msg.topics = topics @@ -51,7 +51,7 @@ proc init*(T: type HistoryResponse, buffer: seq[byte]): ProtoResult[T] = var messages: seq[seq[byte]] - discard ? pb.getField(1, msg.requestID) + discard ? pb.getField(1, msg.uuid) discard ? pb.getRepeatedField(2, messages) for buf in messages: @@ -80,7 +80,7 @@ proc init*(T: type StoreRPC, buffer: seq[byte]): ProtoResult[T] = method encode*(query: HistoryQuery): ProtoBuffer = result = initProtoBuffer() - result.write(1, query.requestID) + result.write(1, query.uuid) for topic in query.topics: result.write(2, topic) @@ -88,7 +88,7 @@ method encode*(query: HistoryQuery): ProtoBuffer = method encode*(response: HistoryResponse): ProtoBuffer = result = initProtoBuffer() - result.write(1, response.requestID) + result.write(1, response.uuid) for msg in response.messages: result.write(2, msg.encodeMessage()) @@ -103,7 +103,7 @@ method encode*(response: StoreRPC): ProtoBuffer = result.write(2, response.encode().buffer) proc query(w: WakuStore, query: HistoryQuery): HistoryResponse = - result = HistoryResponse(requestID: query.requestID, messages: newSeq[Message]()) + result = HistoryResponse(uuid: query.uuid, messages: newSeq[Message]()) for msg in w.messages: for topic in query.topics: if topic in msg.topicIDs: