pub struct ObjectFetcher<PG>{ /* private fields */ }
Expand description
Object fetcher for the Subspace DSN.
Implementations§
Source§impl<PG> ObjectFetcher<PG>
impl<PG> ObjectFetcher<PG>
Sourcepub fn new(piece_getter: Arc<PG>, max_object_len: usize) -> Self
pub fn new(piece_getter: Arc<PG>, max_object_len: usize) -> Self
Create a new object fetcher with the given configuration.
max_object_len
is the amount of data bytes we’ll read for a single object before giving
up and returning an error. In this implementation, it is limited to
max_supported_object_length()
, which is much larger than the maximum consensus block
size.
Sourcepub async fn fetch_objects(
&self,
mappings: GlobalObjectMapping,
) -> Result<Vec<Vec<u8>>, Error>
pub async fn fetch_objects( &self, mappings: GlobalObjectMapping, ) -> Result<Vec<Vec<u8>>, Error>
Assemble the objects in mapping
by fetching necessary pieces using the piece getter, and
putting the objects’ bytes together.
Checks the objects’ hashes to make sure the correct bytes are returned.
For efficiency, objects in a batch should be sorted by increasing piece index. Objects with the same piece index should be sorted by increasing offset. This allows the last piece to be re-used for the next object in the batch.
Batches should be split if the gap between object piece indexes is 6 or more. Those objects can’t share any pieces, because a maximum-sized object only uses 6 pieces.
Auto Trait Implementations§
impl<PG> Freeze for ObjectFetcher<PG>
impl<PG> RefUnwindSafe for ObjectFetcher<PG>where
PG: RefUnwindSafe,
impl<PG> Send for ObjectFetcher<PG>
impl<PG> Sync for ObjectFetcher<PG>
impl<PG> Unpin for ObjectFetcher<PG>
impl<PG> UnwindSafe for ObjectFetcher<PG>where
PG: RefUnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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