Skip to content

Commit

Permalink
Fix conflict & slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
SionoiS committed Apr 24, 2024
1 parent c89b00a commit f9e154e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion waku/waku_api/rest/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import
../../waku/waku_api/rest/filter/handlers as rest_filter_api,
../../waku/waku_api/rest/lightpush/handlers as rest_lightpush_api,
../../waku/waku_api/rest/store/handlers as rest_store_api,
../../waku/waku_api/rest/legacy_store/handlers as rest_store_legacy_api,
../../waku/waku_api/rest/health/handlers as rest_health_api,
../../waku/waku_api/rest/admin/handlers as rest_admin_api,
../../waku/waku_core/topics
Expand Down Expand Up @@ -172,7 +173,8 @@ proc startRestServerProtocolSupport*(
else:
none(DiscoveryHandler)

installStoreApiHandlers(router, node, storeDiscoHandler)
rest_store_api.installStoreApiHandlers(router, node, storeDiscoHandler)
rest_store_legacy_api.installStoreApiHandlers(router, node, storeDiscoHandler)

## Light push API
if conf.lightpushnode != "" and node.wakuLightpushClient != nil:
Expand Down
22 changes: 11 additions & 11 deletions waku/waku_store/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,8 @@ proc new*(
WakuStoreClient(peerManager: peerManager, rng: rng)

proc sendStoreRequest(
self: WakuStoreClient, request: StoreQueryRequest, peer: RemotePeerInfo
self: WakuStoreClient, request: StoreQueryRequest, connection: Connection
): Future[StoreQueryResult] {.async, gcsafe.} =
if request.paginationCursor.isSome() and request.paginationCursor.get() == EmptyCursor:
return err(StoreError(kind: ErrorCode.BAD_REQUEST, cause: "invalid cursor"))

let connection = (await self.peerManager.dialPeer(peer, WakuStoreCodec)).valueOr:
waku_store_errors.inc(labelValues = [dialFailure])

return err(StoreError(kind: ErrorCode.PEER_DIAL_FAILURE, address: $peer))

var req = request

req.requestId = generateRequestId(self.rng)
Expand All @@ -59,6 +51,14 @@ proc sendStoreRequest(
return ok(res)

proc query*(
self: WakuStoreClient, req: StoreQueryRequest, peer: RemotePeerInfo
self: WakuStoreClient, request: StoreQueryRequest, peer: RemotePeerInfo
): Future[StoreQueryResult] {.async, gcsafe.} =
return await self.sendStoreRequest(req, peer)
if request.paginationCursor.isSome() and request.paginationCursor.get() == EmptyCursor:
return err(StoreError(kind: ErrorCode.BAD_REQUEST, cause: "invalid cursor"))

let connection = (await self.peerManager.dialPeer(peer, WakuStoreCodec)).valueOr:
waku_store_errors.inc(labelValues = [dialFailure])

return err(StoreError(kind: ErrorCode.PEER_DIAL_FAILURE, address: $peer))

return await self.sendStoreRequest(request, connection)

0 comments on commit f9e154e

Please sign in to comment.