broadcast method
NdkBroadcastResponse
broadcast({
- required Nip01Event nostrEvent,
- Iterable<
String> ? specificRelays, - EventSigner? customSigner,
- double? considerDonePercent,
- Duration? timeout,
low level nostr broadcast using inbox/outbox (gossip)
specificRelays
disables inbox/outbox (gossip) and broadcasts to the relays specified. Useful for NostrWalletConnect
customSigner
if you want to use a different signer than the one from currently logged in user in Accounts
considerDonePercent
the percentage (0.0, 1.0) of relays that need to respond with "OK" for the broadcast to be considered done (overrides the default value)
timeout
the timeout for the broadcast (overrides the default timeout)
returns
a NdkBroadcastResponse object containing the result => success per relay
Implementation
NdkBroadcastResponse broadcast({
required Nip01Event nostrEvent,
Iterable<String>? specificRelays,
EventSigner? customSigner,
double? considerDonePercent,
Duration? timeout,
}) {
final myConsiderDonePercent = considerDonePercent ?? _considerDonePercent;
final myTimeout = timeout ?? _timeout;
final broadcastState = BroadcastState(
considerDonePercent: myConsiderDonePercent,
timeout: myTimeout,
);
// register broadcast state
_globalState.inFlightBroadcasts[nostrEvent.id] = broadcastState;
final signer =
nostrEvent.sig == '' ? _checkSinger(customSigner: customSigner) : null;
return _engine.handleEventBroadcast(
nostrEvent: nostrEvent,
signer: signer,
specificRelays: specificRelays,
doneStream: broadcastState.stateUpdates
.map((state) => state.broadcasts.values.toList()),
);
}