pub struct WalletSyncStatusResult {
pub phase: WalletSyncPhase,
pub peak_height: Option<u32>,
pub chia_peer_count: Option<u32>,
}Expand description
control.wallet.syncStatus — is the wallet’s chain replica being kept current, how far has it
got, and how many Chia peers is it using?
§Synced means CAUGHT UP AND CONNECTED, not ONCE CAUGHT UP
phase is WalletSyncPhase::Synced only when the initial catch-up completed
AND at least one Chia peer connection is live right now. A wallet that caught up yesterday and
has been offline since MUST report Syncing. This makes phase == Synced STRICTLY STRONGER than WalletPeakResult::synced, which reflects only the
completed-catch-up flag: Synced implies that flag, the flag does not imply Synced. Both types
say so, because the two notions share a word and nothing but the docs would keep them aligned.
This is the whole reason the method exists. A surface asking does my wallet stay synced? cannot be answered by a flag that a disconnected wallet still sets.
Synced is nevertheless not a freshness guarantee. Being connected is not being up to date:
a live connection to a stalled or lagging peer satisfies the predicate while the replica goes
stale. The phase reports that catch-up finished and a peer is attached — that nothing KNOWN is
preventing the replica from being kept current — and a consumer needing actual freshness must
compare peak_height against something, not read this phase. Stating the
limit is the point: this family exists because a surface asserted more than it knew.
§The height NEVER comes from a third-party oracle
peak_height is the node’s OWN replica’s height or null. It MUST NOT fall
back to the coinset oracle. control.wallet.peak deliberately does fall back, because it answers
a different question — what height is the chain at? — whereas this field answers how far has
this replica got? An oracle’s height here would report a caller’s own sync progress using a
number the replica never reached, which is precisely the reading a progress display makes.
§chia_peer_count: 0 is the disambiguator, not a fourth phase
A sync that is running while connected to nothing reports Syncing with a count of 0, and a
consumer SHOULD render the count alongside the phase for exactly that reason: “syncing — no
peers” is honest where a bare “syncing” implies progress that is not happening. null means the
node cannot observe the count at all and licenses no claim about connectivity either way.
§These are CHIA peers, not DIG peers
chia_peer_count counts CHIA FULL-NODE peers the wallet’s chain sync is
connected to. It is NOT the DIG gossip/content peer count from control.peerStatus
(connected_peers / relay_peer_count); the two are unrelated numbers that move independently.
A surface that placed one of them beside a wallet sync status under a bare label of “peers” would
assert something false — a node with many DIG peers and no Chia peer is a wallet that is not
syncing at all. A caller that wants BOTH networks’ counts reads PeerCountsResult, which is
the one call that answers for each network by name.
§The duplicated field is ONE observation
chia_peer_count also appears on PeerCountsResult, and the two are
the SAME observation: a conforming node MUST serve them from one source, and they MUST agree
within a single node’s view. The field is duplicated rather than moved because it is load-bearing
HERE — chia_peer_count: 0 beside Syncing is the honest “syncing — no peers” state, and a
phase separated from its count reads as a contradiction. A DIG content-network count, by
contrast, is not a wallet fact and does not vary with wallet state, which is why it is absent
from this type rather than added for symmetry.
§Which field combinations are meaningful
{phase: Synced, peak_height: null} MUST NOT be emitted. A node records its peak BEFORE it marks
the initial catch-up complete, so a completed catch-up always has a height behind it; a Synced
with no height describes a state a conforming node cannot be in, and a consumer has no honest
reading for it.
{phase: NotStarted, peak_height: <some height>} is the opposite case, and is EXPLICITLY
LEGITIMATE — it is not a contradiction and MUST NOT be “fixed”. The height is persisted in the
wallet database, while the phase describes whether a sync is running IN THIS PROCESS. A node that
synced yesterday and has just restarted reports exactly this, and reports it truthfully: here is
the height I reached, and no sync is running right now. Forbidding the pair would force a
conforming node to either fabricate a phase it is not in or discard a height it genuinely has —
which is the dishonesty this method was created to prevent. peak_height: null alongside
NotStarted is equally legitimate and means a wallet that has never synced at all.
§No confirmation-depth arithmetic happens here
The height recorded is the height of the LAST EXISTING block the peer view reported
(NewPeakWallet.height / RespondPuzzleState.height from a real full node). This surface
performs no depth arithmetic. dig_ecosystem#2483 records that peak_height’s meaning differs
between a simulator (the NEXT height) and a full node (the last existing one), so a consumer
computing depth must floor its own input rather than assume a convention.
Fields§
§phase: WalletSyncPhaseWhich of the three states the wallet’s chain sync is in. See WalletSyncPhase.
peak_height: Option<u32>The replica’s own peak height, or null when it has none — never height 0 as a stand-in for
unknown, and never an oracle’s height. See the type docs.
chia_peer_count: Option<u32>How many CHIA full-node peers the sync is connected to. 0 is an observed zero; null means
the node cannot observe the count. Not the DIG peer count — see the type docs.
Trait Implementations§
Source§impl Clone for WalletSyncStatusResult
impl Clone for WalletSyncStatusResult
Source§fn clone(&self) -> WalletSyncStatusResult
fn clone(&self) -> WalletSyncStatusResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more