diff --git a/library/libstorage.h b/library/libstorage.h index e5e0dbbb..75463fc9 100644 --- a/library/libstorage.h +++ b/library/libstorage.h @@ -225,7 +225,7 @@ extern "C" // This is a **temporary** API and will likely be gone by mainnet. // // The callback returns a string containing the previous value for - // private queries ("true" if the were enabled, or "false" otherwise). + // private queries ("true" if they were enabled, or "false" otherwise). int storage_toggle_private_queries( void *ctx, bool enabled, diff --git a/library/storage_thread_requests/requests/node_mix_request.nim b/library/storage_thread_requests/requests/node_mix_request.nim index 4039c6af..5c089852 100644 --- a/library/storage_thread_requests/requests/node_mix_request.nim +++ b/library/storage_thread_requests/requests/node_mix_request.nim @@ -21,5 +21,8 @@ proc destroyShared(self: ptr NodeMixRequest) = proc process*( self: ptr NodeMixRequest, storage: ptr StorageServer ): Future[Result[string, string]] {.async: (raises: []).} = + defer: + destroyShared(self) + let previous = storage[].node.togglePrivateQueries(self.privateQueries) return ok($previous) diff --git a/storage/discovery.nim b/storage/discovery.nim index 67dff5b4..b498dd81 100644 --- a/storage/discovery.nim +++ b/storage/discovery.nim @@ -87,9 +87,9 @@ proc findPeer*( return PeerRecord.none -method findViaMix( +method findViaMix*( d: Discovery, cid: Cid -): Future[?!seq[SignedPeerRecord]] {.async: (raises: [CancelledError]).} = +): Future[?!seq[SignedPeerRecord]] {.base, async: (raises: [CancelledError]).} = var candidates = d.dhtMixProxies shuffle(candidates) @@ -105,7 +105,7 @@ method findViaMix( method findDirect*( d: Discovery, cid: Cid -): Future[?!seq[SignedPeerRecord]] {.async: (raises: [CancelledError]).} = +): Future[?!seq[SignedPeerRecord]] {.base, async: (raises: [CancelledError]).} = try: return (await d.protocol.getProviders(cid.toNodeId())).mapFailure except CancelledError as exc: diff --git a/tests/cbindings/storage.c b/tests/cbindings/storage.c index ac26a954..354b81d9 100644 --- a/tests/cbindings/storage.c +++ b/tests/cbindings/storage.c @@ -813,13 +813,14 @@ int check_toggle_private_queries(void *storage_ctx) } int ret = is_resp_ok(r, &res); - printf("B\n"); if (strcmp(res, "false") != 0) { fprintf(stderr, "toggle private queries content mismatch, res:%s\n", res); + free(res); return RET_ERR; } + free(res); // Second toggle is true -> false r = alloc_resp(); if (storage_toggle_private_queries(storage_ctx, false, (StorageCallback)callback, r) != RET_OK) @@ -832,9 +833,11 @@ int check_toggle_private_queries(void *storage_ctx) if (strcmp(res, "true") != 0) { fprintf(stderr, "toggle private queries content mismatch, res:%s\n", res); + free(res); return RET_ERR; } + free(res); return RET_OK; }