logos-messaging-nim/logos_delivery/api/messaging_client_interface.nim
NagyZoltanPeter 6bd8873094
Wire KernelInterface onto Waku; non-API broker conversion
Squash of the kernel-wiring work (d86f0651..535fe2c9):
- Don't exercise FFI of Brokers
- Fix tests and examples to compile; verify product unchanged
- bump nim-brokers to v3.1.3
- Events dropListeners changed to async
- WIP + finalize KernelInterface <-> Waku wiring
2026-06-19 08:50:18 +02:00

49 lines
1.6 KiB
Nim

## MessagingClientInterface — the messaging API (waku/api) minus createNode.
##
## Node creation lives in the facade (LogosDeliveryInterface); this interface exposes
## subscribe / unsubscribe / send only.
import results, chronos
import brokers/broker_interface
import logos_delivery/api/types
export types
BrokerInterface(MessagingClientInterface):
EventBroker:
# Event emitted when a message is sent to the network
type MessageSentEvent* = object
requestId*: RequestId
messageHash*: string
EventBroker:
# Event emitted when a message send operation fails
type MessageErrorEvent* = object
requestId*: RequestId
messageHash*: string
error*: string
EventBroker:
# Confirmation that a message has been correctly delivered to some neighbouring nodes.
type MessagePropagatedEvent* = object
requestId*: RequestId
messageHash*: string
EventBroker:
# Event emitted when a message is received via Waku
type MessageReceivedEvent* = object
messageHash*: string
message*: WakuMessage
RequestBroker:
proc subscribe(contentTopic: ContentTopic): Future[Result[void, string]] {.async.}
RequestBroker:
proc unsubscribe(contentTopic: ContentTopic): Future[Result[void, string]] {.async.}
RequestBroker:
# Returns the RequestId in its string form. Named `sendMessage` (not `send`)
# because broker request verbs must be globally unique across all interfaces
# in the library, and ReliableChannelManagerInterface also has a send.
proc send(envelope: MessageEnvelope): Future[Result[RequestId, string]] {.async.}