Skip to main content

WalletSyncStatusResult

Struct WalletSyncStatusResult 

Source
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: WalletSyncPhase

Which 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

Source§

fn clone(&self) -> WalletSyncStatusResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WalletSyncStatusResult

Source§

impl Debug for WalletSyncStatusResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WalletSyncStatusResult

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for WalletSyncStatusResult

Source§

impl PartialEq for WalletSyncStatusResult

Source§

fn eq(&self, other: &WalletSyncStatusResult) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for WalletSyncStatusResult

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WalletSyncStatusResult

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.