fix copilot suggestions

This commit is contained in:
gmega 2026-06-16 15:46:56 -03:00
parent 562c537ec7
commit 31b7d0902a
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
4 changed files with 11 additions and 5 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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:

View File

@ -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;
}