pub struct P2pProvider { /* private fields */ }Expand description
P2P header view rooted in a trusted checkpoint and existing local cache.
Typed results establish the limited verification described by VerifiedBlock.
Implementations§
Source§impl P2pProvider
impl P2pProvider
pub fn new(chain: Chain, cache_dir: &Path) -> Result<Self, Error>
pub fn with_peers( chain: Chain, cache_dir: &Path, anchor: Anchor, pinned: Vec<SocketAddr>, ) -> Result<Self, Error>
Sourcepub fn with_bootstrap(
cache_dir: &Path,
bootstrap: HeaderBootstrap,
pinned: Vec<SocketAddr>,
) -> Result<Self, Error>
pub fn with_bootstrap( cache_dir: &Path, bootstrap: HeaderBootstrap, pinned: Vec<SocketAddr>, ) -> Result<Self, Error>
Open a checkpoint-relative view with authenticated preceding context.
The operator still trusts the bootstrap anchor’s chain membership and
height; its context does not establish full consensus or earlier scan
coverage. Construction opens the local cache without starting a worker
or network connections. warm or the first verified read starts it.
pub fn warm(&self) -> Result<(), Error>
pub fn progress(&self) -> Progress
Sourcepub fn target_height(&self) -> Option<u64>
pub fn target_height(&self) -> Option<u64>
Absolute height header sync heads for: the best height connected peers
announced, never below the local tip. Announced, not proven. None
while no peer is connected or none has announced a height.
pub fn state(&self) -> LightSync
pub fn synced(&self) -> bool
pub fn ready(&self) -> bool
Sourcepub fn verified_tip(&self) -> Result<(u64, Header), Error>
pub fn verified_tip(&self) -> Result<(u64, Header), Error>
Snapshot of the active header tip, relative to the configured trusted
checkpoint and local header cache, not full consensus validation.
Starts the worker if cold and fails immediately while it is not ready.
Stale-tip refresh waits at most P2P_BLOCK_TIMEOUT_SECS for its reply;
a full command queue is refused immediately. No other source is used.
Sourcepub fn verified_header(&self, height: u64) -> Result<Header, Error>
pub fn verified_header(&self, height: u64) -> Result<Header, Error>
Active header at height, under the same trust and readiness contract
as verified_tip(). Heights before the checkpoint are unavailable.
Sourcepub fn verified_block(&self, height: u64) -> Result<VerifiedBlock, Error>
pub fn verified_block(&self, height: u64) -> Result<VerifiedBlock, Error>
Fetch by the captured active header’s hash, check block integrity, and
refuse the result if that header was replaced or removed during fetch.
Retains original bytes; see VerifiedBlock for verification limits.
Readiness and queue admission fail fast. Refresh and block replies each
wait at most P2P_BLOCK_TIMEOUT_SECS; no router or fallback is involved.