Ivan FB e59703fad7
Migrate FFI to nim-ffi v0.2.0-rc.3 (typed procs, direct params)
Rewrite the C FFI over the new per-layer APIs using nim-ffi v0.2.0 typed
{.ffiCtor.}/{.ffiDtor.}/{.ffi.}/{.ffiEvent.} + CBOR, replacing the
hand-written cstring/JSON bridge and the declare/lifecycle scaffolding.

Final API shape from the start (no intermediate request wrappers):
- every {.ffi.} proc takes its parameters directly; the macro bundles them
  into the per-proc CBOR request, so no `*Request` objects are needed
- WakuMessage rides the wire directly (its fields are CBOR-serializable)
- multi-parameter {.ffiEvent.} via the rc.3 envelope synthesis
- events are fed by internal nim-broker listeners (no AppCallbacks)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 13:14:40 +02:00

32 lines
1.1 KiB
Nim

proc discv5_update_bootnodes*(
self: LogosDelivery, bootnodes: string
): Future[Result[string, string]] {.ffi.} =
## `bootnodes` is a JSON array of ENRs, e.g. `["enr:...", "enr:..."]`.
(await self.waku.discv5UpdateBootnodes(bootnodes)).isOkOr:
return err(error)
return ok("")
proc dns_discovery*(
self: LogosDelivery, enrTreeUrl: string, nameDnsServer: string, timeoutMs: int
): Future[Result[string, string]] {.ffi.} =
let nodes = (await self.waku.dnsDiscovery(enrTreeUrl, nameDnsServer, timeoutMs)).valueOr:
return err(error)
return ok(nodes.join(","))
proc start_discv5*(self: LogosDelivery): Future[Result[string, string]] {.ffi.} =
(await self.waku.startDiscv5()).isOkOr:
return err(error)
return ok("")
proc stop_discv5*(self: LogosDelivery): Future[Result[string, string]] {.ffi.} =
(await self.waku.stopDiscv5()).isOkOr:
return err(error)
return ok("")
proc peer_exchange_request*(
self: LogosDelivery, numPeers: uint64
): Future[Result[string, string]] {.ffi.} =
let n = (await self.waku.peerExchangeRequest(numPeers)).valueOr:
return err(error)
return ok($n)