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.34`, which shares `chia-protocol = 0.36.1` with
31//! `dig-chainsource-interface = 0.3`. That single `chia-protocol` version is REQUIRED: an SDK on a
32//! different `chia-protocol` line yields `Coin`/`CoinSpend`/`Bytes32` types that would not unify
33//! with the interface the provider implements. The SDK version is chosen to MATCH the interface's
34//! `chia-protocol`, never the other way around.
35
36mod bridge;
37mod cache;
38mod client;
39mod config;
40mod connect;
41mod error;
42mod fetcher;
43mod ordering;
44mod provider;
45
46pub use client::{ChiaLightClient, SubmitOutcome, DEFAULT_PROVIDER_PRIORITY};
47pub use config::{ChiaNetwork, ChiaPeerConfig};
48pub use error::ChiaPeerError;
49pub use fetcher::{CoinStateFetcher, PeerFetcher};
50pub use provider::ChiaPeerProvider;
51
52// Re-export the canonical interface types a consumer needs to register the provider, so it need not
53// depend on `dig-chainsource-interface` separately just to name them.
54pub use dig_chainsource_interface::{
55    ChainSource, ChainSourceError, ChainSourceProvider, ProviderInfo, ProviderKind,
56};
57
58/// The crate version, sourced from `Cargo.toml` at build time.
59pub const VERSION: &str = env!("CARGO_PKG_VERSION");
60
61#[cfg(test)]
62mod tests {
63    use super::VERSION;
64
65    #[test]
66    fn version_is_reported() {
67        assert!(!VERSION.is_empty());
68    }
69}