sendCountEventToRelaysAsync method
Future<NostrCountResponse>
sendCountEventToRelaysAsync(
- NostrCountEvent countEvent, {
- required Duration timeout,
override
Implementation
@override
Future<NostrCountResponse> sendCountEventToRelaysAsync(
NostrCountEvent countEvent, {
required Duration timeout,
}) {
final completer = Completer<NostrCountResponse>();
var okTriggered = false;
Future.delayed(timeout, () {
if (!okTriggered) {
throw TimeoutException(
'the count event with subscription id: ${countEvent.subscriptionId} has timed out after: ${timeout.inSeconds} seconds',
);
}
});
final serialized = countEvent.serialized();
_registerOnCountCallBack(countEvent.subscriptionId, (countRes) {
okTriggered = true;
completer.complete(countRes);
});
_runFunctionOverRelationIteration((relay) {
relay.socket.add(serialized);
utils.log(
'count event with subscription id: ${countEvent.subscriptionId} is sent to relay with url: ${relay.url}',
);
});
return completer.future;
}