Skip to main content

P2pProvider

Struct P2pProvider 

Source
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

Source

pub fn new(chain: Chain, cache_dir: &Path) -> Result<Self, Error>

Source

pub fn with_peers( chain: Chain, cache_dir: &Path, anchor: Anchor, pinned: Vec<SocketAddr>, ) -> Result<Self, Error>

Source

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.

Source

pub fn warm(&self) -> Result<(), Error>

Source

pub fn progress(&self) -> Progress

Source

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.

Source

pub fn state(&self) -> LightSync

Source

pub fn synced(&self) -> bool

Source

pub fn ready(&self) -> bool

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for P2pProvider

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Provider for P2pProvider

Source§

fn label(&self) -> String

Source§

fn evidence(&self) -> Evidence

Source§

fn block_encoding(&self) -> BlockEncoding

Source§

fn supports(&self, method: &str) -> bool

Source§

fn call( &self, chain: Chain, method: &str, args: &[Value], ) -> Result<Value, Error>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more