Skip to content

Commit

Permalink
store_request: tiny compilation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Dec 13, 2024
1 parent 990847f commit 1b9c3fa
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ type StoreRequest* = object
peerAddr: cstring
timeoutMs: cint

func fromJsonNode(T: type StoreRequest, jsonContent: JsonNode): StoreQueryRequest =
func fromJsonNode(
T: type StoreRequest, jsonContent: JsonNode
): Result[StoreQueryRequest, string] =
let contentTopics = collect(newSeq):
for cTopic in jsonContent["content_topics"].getElems():
cTopic.getStr()
Expand Down Expand Up @@ -64,14 +66,17 @@ func fromJsonNode(T: type StoreRequest, jsonContent: JsonNode): StoreQueryReques
else:
none(uint64)

let startTime = ?jsonContent.getProtoInt64("time_start")
let endTime = ?jsonContent.getProtoInt64("time_end")

return ok(
StoreQueryRequest(
requestId: jsonContent["request_id"].getStr(),
includeData: jsonContent["include_data"].getBool(),
pubsubTopic: pubsubTopic,
contentTopics: contentTopics,
startTime: ?jsonContent.getProtoInt64("time_start"),
endTime: ?jsonContent.getProtoInt64("time_end"),
startTime: startTime,
endTime: endTime,
messageHashes: msgHashes,
paginationCursor: paginationCursor,
paginationForward: paginationForward,
Expand Down Expand Up @@ -110,12 +115,12 @@ proc process_remote_query(
if jsonContentRes.isErr():
return err("StoreRequest failed parsing store request: " & jsonContentRes.error.msg)

let storeQueryRequest = StoreRequest.fromJsonNode(jsonContentRes.get())
let storeQueryRequest = ?StoreRequest.fromJsonNode(jsonContentRes.get())

let peer = peers.parsePeerInfo(($self[].peerAddr).split(",")).valueOr:
return err("StoreRequest failed to parse peer addr: " & $error)

let queryResponse = (await waku.node.wakuStoreClient.query(?storeQueryRequest, peer)).valueOr:
let queryResponse = (await waku.node.wakuStoreClient.query(storeQueryRequest, peer)).valueOr:
return err("StoreRequest failed store query: " & $error)

return ok($(%*queryResponse)) ## returning the response in json format
Expand Down

0 comments on commit 1b9c3fa

Please sign in to comment.