Skip to main content

chia_peer/
lib.rs

1//! # chia-peer — DIG Chia light-client connectivity (dig-node seam 1)
2//!
3//! A thin wrapper that CONFIGURES and DRIVES [`chia_wallet_sdk`]'s light-client `Peer` so a DIG node
4//! can act as a Chia wallet-protocol client: connect to full nodes, subscribe to coin/puzzle-hash
5//! state, track the peak, handle reorgs, and submit spend bundles.
6//!
7//! The heavy lifting — the wallet-protocol wire, TLS, DNS-introducer discovery, coin-state
8//! subscription, and transaction submission — lives in the SDK. This crate adds only DIG glue:
9//! IPv6-first dialing (§5.2), a reorg-aware subscription cache, reconnect-with-re-arm, and a
10//! [`ChainSource`] read facade.
11//!
12//! ## Shape
13//!
14//! - [`ChiaLightClient`] — connect, [`subscribe_coins`](ChiaLightClient::subscribe_coins),
15//!   [`subscribe_puzzle_hashes`](ChiaLightClient::subscribe_puzzle_hashes),
16//!   [`submit_spend`](ChiaLightClient::submit_spend), [`peak`](ChiaLightClient::peak),
17//!   [`unsubscribe_coins`](ChiaLightClient::unsubscribe_coins),
18//!   [`reconnect`](ChiaLightClient::reconnect), and
19//!   [`as_chain_source_provider`](ChiaLightClient::as_chain_source_provider).
20//! - [`ChiaPeerProvider`] — the synchronous, fail-closed [`ChainSource`] provider dig-node registers.
21//!
22//! ## Reads are fail-closed
23//!
24//! Through the provider, `Ok(None)`/empty means the peer reliably reported absence; any
25//! transport/subscription-gap failure is an `Err`, never a false `Ok(None)` — the crux of the
26//! [`dig_chainsource_interface`] contract.
27//!
28//! ## The SDK version pairing
29//!
30//! This crate pins `chia-wallet-sdk = 0.30`, which shares `chia-protocol = 0.26` with
31//! `dig-chainsource-interface`. That single `chia-protocol` version is REQUIRED: a newer SDK pulls a
32//! newer `chia-protocol` whose types would not unify with the interface the provider implements.
33
34mod bridge;
35mod cache;
36mod client;
37mod config;
38mod connect;
39mod error;
40mod fetcher;
41mod ordering;
42mod provider;
43
44pub use client::{ChiaLightClient, SubmitOutcome, DEFAULT_PROVIDER_PRIORITY};
45pub use config::{ChiaNetwork, ChiaPeerConfig};
46pub use error::ChiaPeerError;
47pub use fetcher::{CoinStateFetcher, PeerFetcher};
48pub use provider::ChiaPeerProvider;
49
50// Re-export the canonical interface types a consumer needs to register the provider, so it need not
51// depend on `dig-chainsource-interface` separately just to name them.
52pub use dig_chainsource_interface::{
53    ChainSource, ChainSourceError, ChainSourceProvider, ProviderInfo, ProviderKind,
54};
55
56/// The crate version, sourced from `Cargo.toml` at build time.
57pub const VERSION: &str = env!("CARGO_PKG_VERSION");
58
59#[cfg(test)]
60mod tests {
61    use super::VERSION;
62
63    #[test]
64    fn version_is_reported() {
65        assert!(!VERSION.is_empty());
66    }
67}