1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//! # dig-peer-protocol
//!
//! The DIG Network peer wire — a **native** protocol, plus the narrow chia surface a DIG node
//! needs to also speak to chia full nodes.
//!
//! ## The native DIG wire
//!
//! [`DigMessage`] is the envelope for every DIG message: a raw `u8` opcode, an optional
//! correlation id, and a [`Bytes`] payload, encoded by this crate and nothing else. It carries
//! the `200..=222` DIG opcode band, which `chia_protocol::Message` structurally cannot express —
//! its `ProtocolMessageTypes` is a closed `#[repr(u8)]` enum with no `Unknown(u8)`, so a DIG
//! opcode is neither constructible nor decodable through it, and one inbound DIG frame drops a
//! whole `chia-sdk-client` connection rather than that one frame.
//!
//! DIG answered that with vendored forks of `chia-protocol` and `chia-sdk-client`. This crate
//! replaces the forks: [`DigLink`] is a websocket peer link written directly against the wire
//! format, and the DIG types it carries — [`Bytes`], [`NodeType`], [`DigMessage`],
//! [`DigMessageType`], [`RegisterPeer`], [`RegisterAck`] — are DIG's own.
//!
//! ## What is deliberately still chia, and why
//!
//! Decoupling from `chia-protocol` is not the same as decoupling from every crate whose name
//! starts with `chia`. Two are kept ON PURPOSE. **Do not "finish the decoupling" by removing
//! them** — they were assessed and retained:
//!
//! - **`chia-traits` ([`Streamable`]) and `chia_streamable_macro` ([`macro@streamable`])** — a
//! serialization trait and a derive macro. Neither has the property this crate is escaping:
//! there is no closed enum and no private-field wire authority in either. They serialize the
//! *bodies* of DIG messages, and they do it with an encoding that is already live on the
//! network. Replacing them would mean owning a serializer — new surface, and a fresh
//! byte-identity risk — to buy nothing that matters.
//! - **`chia-protocol`'s `ChiaProtocolMessage` and `TimestampedPeerInfo`, and
//! `chia-sdk-client`** — these serve genuine *chia* traffic. A DIG node talks to chia full
//! nodes too: [`DigLink`]'s typed `send`/`request` derive a chia opcode from
//! `ChiaProtocolMessage`, [`RespondPeersIntroducer`] is chia opcode 64, and
//! [`OpcodeRateLimits`] re-keys chia's own published rate-limit table so a chia opcode is
//! limited exactly as a stock peer would limit it. Chia types for chia traffic is the design,
//! not a leftover.
//!
//! There is no blanket `pub use chia_protocol::*`. A glob re-export is how chia types reach
//! consumers that never asked for them, and it made a chia version bump a breaking change to
//! every downstream crate. What a chia-full-node path needs is named explicitly below.
//!
//! ## Feature flags
//!
//! | Flag | Forwards to | Effect |
//! |------|-------------|--------|
//! | `native-tls` | `chia-sdk-client/native-tls` | OS-native TLS; enables `Client`, `ClientState`, `Connector`, `create_native_tls_connector`, `DigLink::connect` |
//! | `rustls` | `chia-sdk-client/rustls` | Pure-Rust TLS; enables `Client`, `ClientState`, `Connector`, `create_rustls_connector`, `DigLink::connect` |
//!
//! Neither is enabled by default. Without one, the TLS-dependent items above are unavailable;
//! [`DigLink::from_websocket`] and [`DigLink::from_server_websocket`] stay available, since
//! adopting an already-established socket needs no TLS backend of its own.
// ============================================================================
// Re-export: chia-protocol — NAMED, for chia-full-node paths only
// ============================================================================
// Explicitly not a glob. `ChiaProtocolMessage` is what `DigLink`'s typed send/request bound
// their generics on, and `TimestampedPeerInfo` is a field of chia opcode 64; a consumer needing
// any other chia wire type depends on `chia-protocol` directly and says so in its own manifest.
pub use ;
// ============================================================================
// Re-export: chia-sdk-client (peer IO, TLS, rate limiting)
// ============================================================================
// Backend-agnostic types — always available.
pub use ;
// `Client`, `ClientState`, and `Connector` require a TLS backend in `chia-sdk-client`.
// Enable either the `native-tls` or `rustls` feature to use them.
pub use ;
pub use create_native_tls_connector;
pub use create_rustls_connector;
// ============================================================================
// Re-export: chia-ssl (certificate types)
// ============================================================================
pub use ChiaCertificate;
// ============================================================================
// Re-export: chia-traits (serialization)
// ============================================================================
pub use Streamable;
// ============================================================================
// Re-export: chia_streamable_macro (proc macro for wire structs)
// ============================================================================
pub use streamable;
// ============================================================================
// DIG extensions
// ============================================================================
pub use Bytes;
pub use DigMessage;
pub use ;
pub use LinkError;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;