mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-13 09:55:55 +01:00
* pubsub: consolidate into Spec, adopt Arc<SubscriptionId>, and wire through wallet/mint/WS/FFI
Refactor the pub/sub engine to a single Spec trait, move Event alongside it,
and propagate Arc-backed subscription IDs across the stack. This simplifies
generics, clarifies responsibilities, and preserves coalescing +
latest-on-subscribe semantics.
- **Single source of truth:** `Spec` owns `Topic`, `Event`, `SubscriptionId`,
`Context`, new_instance, and fetch_events.
- **Lean & explicit API:** Remove Topic trait split;
`Subscriber::send(Event)` carries sub-ID internally.
- **Performance/ergonomics:** `Arc<SubscriptionId>` avoids heavy clones and
makes channel/task hops trivial.
- Introduce `pub_sub/typ.rs` with:
- trait `Spec`
- trait `Event` colocated with Spec.
- Remove `pub_sub/event.rs` fold `Event` into `typ.rs`.
- Make `Pubsub<S>` generic over `Spec` and store `Arc<S>`.
- The subscriber holds `Arc<SubscriptionId>` and deduplicates the latest
entry per subscription.
- SubscriptionRequest: rename SubscriptionName → SubscriptionId; return
`Arc<...>` from `subscription_name()`.
- Remote consumer (Transport) now parameterized by `Spec`; control types
updated:
- `StreamCtrl<S>`, `SubscribeMessage<S>`, internal caches keyed by
`S::Topic`.
- Mint/wallet:
- Mint: `MintPubSubSpec` (Context = `DynMintDatabase`),
`PubSubManager(Pubsub<MintPubSubSpec>)`.
- Wallet: lightweight MintSubTopics Spec with `Context = ()`.
- IDs go Arc end-to-end:
- cdk-axum WS maps `HashMap<Arc<SubId>, JoinHandle<()>>`, publisher sends
`(Arc<SubId>, NotificationPayload)`.
- `subscription::{Params, WalletParams}` now use `Arc<...>`.
- cdk-ffi conversions & wallet glue updated.
- Integration tests updated for new types.
- Coalescing unchanged: multiple local subs to the same topic are combined
into a single remote sub.
- Backfill via `Spec::fetch_events(topics, Subscriber)`; Subscriber enforces
latest-only dedupe per subscription.
**Result:** a slimmer, more maintainable pub/sub core that’s easier to embed
across mint, wallet, transports, and FFI without sacrificing performance or
semantics.
---------
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
47 lines
1.3 KiB
TOML
47 lines
1.3 KiB
TOML
[package]
|
|
name = "cashu"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
authors = ["CDK Developers"]
|
|
description = "Cashu shared types and crypto utilities, used as the foundation for the CDK and their crates"
|
|
homepage = "https://github.com/cashubtc/cdk"
|
|
repository = "https://github.com/cashubtc/cdk.git"
|
|
rust-version.workspace = true # MSRV
|
|
license.workspace = true
|
|
readme = "README.md"
|
|
|
|
[features]
|
|
default = ["mint", "wallet", "auth"]
|
|
swagger = ["dep:utoipa"]
|
|
mint = []
|
|
wallet = []
|
|
auth = ["dep:strum", "dep:strum_macros", "dep:regex"]
|
|
bench = []
|
|
|
|
[dependencies]
|
|
uuid.workspace = true
|
|
bitcoin.workspace = true
|
|
cbor-diag.workspace = true
|
|
ciborium.workspace = true
|
|
once_cell.workspace = true
|
|
serde.workspace = true
|
|
lightning-invoice.workspace = true
|
|
lightning.workspace = true
|
|
thiserror.workspace = true
|
|
tracing.workspace = true
|
|
url.workspace = true
|
|
utoipa = { workspace = true, optional = true }
|
|
serde_json.workspace = true
|
|
serde_with.workspace = true
|
|
regex = { workspace = true, optional = true }
|
|
strum = { workspace = true, optional = true }
|
|
strum_macros = { workspace = true, optional = true }
|
|
zeroize = "1"
|
|
web-time.workspace = true
|
|
|
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
uuid = { workspace = true, features = ["js"], optional = true }
|
|
|
|
[dev-dependencies]
|
|
bip39.workspace = true
|