pub struct SubtreePrefetchRequest {
pub subtree_roots: Vec<[u8; 32]>,
/* private fields */
}Expand description
Request for subtree prefetch-based sync.
Fetches entire subtrees when divergence is detected in deep trees. More efficient than HashComparison when changes are clustered.
Use when:
- tree depth >
DEEP_TREE_THRESHOLD(3) - divergence <
MAX_DIVERGENCE_RATIO(20%) - Changes are clustered in <=
MAX_CLUSTERED_SUBTREES(5) subtrees
Fields§
§subtree_roots: Vec<[u8; 32]>Root hashes of subtrees to fetch.
Limited to MAX_SUBTREES_PER_REQUEST entries. Use is_valid() to check
bounds after deserialization from untrusted sources.
Implementations§
Source§impl SubtreePrefetchRequest
impl SubtreePrefetchRequest
Sourcepub fn with_depth(subtree_roots: Vec<[u8; 32]>, max_depth: usize) -> Self
pub fn with_depth(subtree_roots: Vec<[u8; 32]>, max_depth: usize) -> Self
Create a request with custom depth limit.
Depth is clamped to MAX_SUBTREE_DEPTH to prevent resource exhaustion.
Sourcepub fn unlimited_depth(subtree_roots: Vec<[u8; 32]>) -> Self
pub fn unlimited_depth(subtree_roots: Vec<[u8; 32]>) -> Self
Create a request with maximum allowed depth (MAX_SUBTREE_DEPTH).
Use this when you want to fetch as deep as safely possible.
The depth() accessor will return MAX_SUBTREE_DEPTH.
Sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
Get the validated depth limit.
Always returns a bounded value:
- Clamps to MAX_SUBTREE_DEPTH if the raw value exceeds it
- Returns MAX_SUBTREE_DEPTH if
max_depthisNone
This ensures consumers always get a safe, bounded depth value regardless of how the request was constructed or deserialized.
Sourcepub fn is_unlimited(&self) -> bool
pub fn is_unlimited(&self) -> bool
Check if this request was created with unlimited depth.
Returns true if created via unlimited_depth() constructor.
Note: depth() will still return MAX_SUBTREE_DEPTH for safety.
Sourcepub fn subtree_count(&self) -> usize
pub fn subtree_count(&self) -> usize
Number of subtrees requested.
Trait Implementations§
Source§impl BorshDeserialize for SubtreePrefetchRequest
impl BorshDeserialize for SubtreePrefetchRequest
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl Clone for SubtreePrefetchRequest
impl Clone for SubtreePrefetchRequest
Source§fn clone(&self) -> SubtreePrefetchRequest
fn clone(&self) -> SubtreePrefetchRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SubtreePrefetchRequest
impl Debug for SubtreePrefetchRequest
Source§impl PartialEq for SubtreePrefetchRequest
impl PartialEq for SubtreePrefetchRequest
impl StructuralPartialEq for SubtreePrefetchRequest
Auto Trait Implementations§
impl Freeze for SubtreePrefetchRequest
impl RefUnwindSafe for SubtreePrefetchRequest
impl Send for SubtreePrefetchRequest
impl Sync for SubtreePrefetchRequest
impl Unpin for SubtreePrefetchRequest
impl UnsafeUnpin for SubtreePrefetchRequest
impl UnwindSafe for SubtreePrefetchRequest
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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