broadcast_queue_shim_for_ndk 0.4.0
broadcast_queue_shim_for_ndk: ^0.4.0 copied to clipboard
Offline-first wrapper around the ndk package's broadcast use case. Persists Nostr events to a local sembast queue and retries until targeted relays acknowledge delivery, return terminal NIP-01 rejecti [...]
0.4.0 #
- Add an optional
pubkeyargument tobroadcast,get,watch, andrebroadcastthat attributes a queued entry to a local account. Records are now keyed by the pair(event.id, pubkey), so the same event queued under two accounts is two independent records.QueuedBroadcastgains apubkeyfield andkey/keyForhelpers. - Add
clearLocalAccountData({required String pubkey})to remove every entry queued under an account (for logout) andclearAllLocalData()to empty the store.pubkeyis a plain label, notevent.pubKey: gift wraps (kind 1059) carry an ephemeral event pubkey, so pass the real sending account for NIP-17 DMs to be clearable. - Entries queued without a
pubkeystay unattributed and keep the bareevent.idas their sembast key, so databases written before 0.4.0 keep working. Unattributed entries are never removed byclearLocalAccountData.
0.3.0 #
- Stop retrying a relay/event pair when the relay returns NIP-01
OK falsewith a terminal machine-readable prefix:pow,blocked,invalid,restricted, orerror. - Add
BroadcastStatus.failed,QueuedBroadcast.terminalErrors, andQueuedBroadcast.failedAtfor entries where every relay is either acked or terminally rejected. - Keep retrying non-terminal failures such as
rate-limited, unknown prefixes, timeouts, no response, and transport errors. - Stop retrying a relay/event pair after 12 consecutive online attempts where the relay is inaccessible.
0.2.1 #
- Fix
int64overflow incomputeBackoffon native platforms (Android, iOS, Linux, macOS, Windows). After ~52 failed attempts (with the default 5s initial delay),pow(2, attempts)wrapped to a negative integer, causingdouble.clampto throwInvalid argument(s). The calculation now uses double arithmetic (pow(2.0, ...)) to avoid the overflow.
0.2.0 #
- Connectivity-aware periodic retries.
OfflineBroadcast.withNdk()now subscribes tondk.connectivity.relayConnectivityChangesand pauses the internal timer while no public relay is connected. Theoffline -> onlineedge triggers an immediate replay.retryNow()always bypasses the check. - Local/private hosts (loopback, RFC1918 IPv4, ULA/link-local IPv6, mDNS
.local) are filtered out when deriving the online signal, so a connected dev relay on localhost cannot mask a real outage. - The default constructor accepts an optional
Stream<bool> onlineSignalfor callers who want to wire their own connectivity source.
0.1.0 #
Initial release.
OfflineBroadcastwrapsndk.broadcastand persists every event to a caller-provided sembast database before attempting to send it.- Required
relayslist at broadcast time. No gossip-based auto-selection. - Per-relay acks are tracked monotonically. An entry is considered
deliveredonly when every targeted relay has acknowledged the event withbroadcastSuccessful: true; once set, the delivery timestamp is never cleared by the shim. - Records are kept after delivery. They are never auto-deleted.
rebroadcast(id)queues a one-shot push to every relay without touching the historical ack set.rebroadcast(id, relay: ...)queues a one-shot push to a specific relay, adding it to the entry's target list if absent.- Retries are driven by an internal periodic timer started via
start(), plus a publicretryNow()callers can wire to connectivity signals. - Backoff is exponential with full jitter, bounded by
initialBackoffandmaxBackoff. - The shim never signs events. Signing remains NDK's responsibility.