Ivan FB 8c274be44d
waku: extract node/query API into waku/api/ and move events
Move the discovery/lightpush/store/ping/debug/health/topics operations into
logos_delivery/waku/api/ and relocate the waku event definitions under
waku/api/events/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 04:15:23 +02:00

32 lines
979 B
Nim

## Waku layer API — store (historical query) operations.
{.push raises: [].}
import results, chronos, chronicles
import logos_delivery/waku/waku
import
logos_delivery/waku/[
waku_core, node/waku_node, waku_store/common, waku_store/client
]
proc storeQuery*(
self: Waku, request: StoreQueryRequest, peer: string, timeoutMs: int
): Future[Result[StoreQueryResponse, string]] {.async.} =
try:
if self.node.wakuStoreClient.isNil():
return err("wakuStoreClient is not mounted")
let remotePeer = parsePeerInfo(peer).valueOr:
return err("storeQuery failed to parse peer addr: " & $error)
let queryFut = self.node.wakuStoreClient.query(request, remotePeer)
if not await queryFut.withTimeout(timeoutMs.milliseconds):
return err("storeQuery timed out")
let queryResponse = queryFut.read().valueOr:
return err("storeQuery failed: " & $error)
return ok(queryResponse)
except CatchableError as e:
return err(e.msg)