pub struct PeerSource<'a> { /* private fields */ }Expand description
The paid BlobSource (#1608): wraps
[crate::open_progressive_pull] behind [BlobSource], scoping every
open to exactly the requested AlignedRange via the
byte_len-bounded pull: the wire StreamRequest carries the field and the
OPEN-side plumbing scopes each pull to the requested range.
One PeerSource serves one gap-driven fetch against one upstream peer — it
holds the pull context (endpoint, target, ctx, ledger, …) but not a
Funder: funding recovery is the acquire loop’s concern, not the source’s.
Borrows its endpoint/slash_domain (the driver, which owns these for the
whole fetch, outlives every open/finish call), but holds the channel
context behind a SHARED Arc<Mutex<PoolContext>> rather than a &'a
borrow. That shared handle is what resolves the #1608 borrow conflict: the
acquire loop mutates the context (crediting a funding recovery step’s new
deposit) while this source also reads it to open each pull. A
&'a PoolContext borrow would freeze it for the whole fetch and forbid that
write; the Arc<Mutex<..>> lets both see one state. open locks it only to
CLONE the context out, then drops the guard before awaiting, so no lock is
ever held across an .await. An open’s snapshot can predate a deposit that
is about to land: it under-states the deposit, never over-states it.
With a Connections map, every open takes a new stream on the target’s
shared connection. Without one, every open dials its own connection.
Implementations§
Source§impl<'a> PeerSource<'a>
impl<'a> PeerSource<'a>
Sourcepub const fn new(
endpoint: &'a Endpoint,
target: EndpointAddr,
ctx: Arc<Mutex<PoolContext>>,
ledger: Arc<PoolLedger>,
slash_domain: &'a Eip712Domain,
expected_signer: Address,
namespace_id: [u8; 32],
max_blob_size_bytes: u64,
max_rate_per_mb: u64,
deadlines: PullDeadlines,
connections: Option<Connections>,
) -> Self
pub const fn new( endpoint: &'a Endpoint, target: EndpointAddr, ctx: Arc<Mutex<PoolContext>>, ledger: Arc<PoolLedger>, slash_domain: &'a Eip712Domain, expected_signer: Address, namespace_id: [u8; 32], max_blob_size_bytes: u64, max_rate_per_mb: u64, deadlines: PullDeadlines, connections: Option<Connections>, ) -> Self
Build a source for one gap-driven fetch against target, paid out of
ledger over ctx’s channel. namespace_id, max_rate_per_mb, and
deadlines are the same buyer-side policy knobs
[crate::open_progressive_pull] takes directly — see its docs.
max_blob_size_bytes is the received-byte ceiling (#1895) the driver reads
back via [BlobSource::max_blob_size_bytes] to abort a fill that crosses it;
0 = unlimited.
connections is the command’s map of one connection per node: with
Some, every open takes a new stream on target’s shared connection
and dials only when target has no live one. With None, every open
dials its own connection. Pass Some only from a single long-lived
runtime (see Connections).
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for PeerSource<'a>
impl<'a> !UnwindSafe for PeerSource<'a>
impl<'a> Freeze for PeerSource<'a>
impl<'a> Send for PeerSource<'a>
impl<'a> Sync for PeerSource<'a>
impl<'a> Unpin for PeerSource<'a>
impl<'a> UnsafeUnpin for PeerSource<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more