Skip to main content

TileHashReader

Struct TileHashReader 

Source
pub struct TileHashReader<S: TileStore> { /* private fields */ }
Expand description

Reads the tiles a root or a proof needs, and no tile that has not been checked against the trusted root: the partial tiles together through the root they fold to, each full tile through its hash in the level above.

Implementations§

Source§

impl<S: TileStore> TileHashReader<S>

Source

pub fn new(store: S, size: u64, root: Hash) -> Self

A reader over store that trusts root to be the root at size.

Source

pub fn store(&self) -> &S

The store behind the reader.

Source

pub fn size(&self) -> u64

Leaves the trusted root covers.

Source

pub fn trusted_root(&self) -> Hash

The trusted root.

Source

pub fn root(&self) -> Result<Hash>

The root recomputed from the partial tiles in the store; an error when it is not the trusted one.

Source

pub fn tile(&self, level: u8, index: u64) -> Result<Rc<Vec<Hash>>>

The hashes of the tile at level and index, checked against the tree. A tile the tree of this size does not have is out of range.

Source

pub fn hash(&self, level: u8, index: u64) -> Result<Hash>

Stored hash index at level: the root over leaves [index * 256^level, (index + 1) * 256^level).

Source

pub fn perfect(&self, start: u64, height: u32) -> Result<Hash>

The root of the perfect subtree over leaves [start, start + 2^height), which must be aligned and inside the tree.

Source

pub fn range_root(&self, lo: u64, hi: u64) -> Result<Hash>

The RFC 9162 root over leaves [lo, hi) of this tree, the same bytes rfc9162::root gives over that slice of leaf hashes.

Source

pub fn inclusion_proof(&self, index: u64) -> Result<Option<Vec<Hash>>>

The audit path for the leaf at index, RFC 9162 section 2.1.3, assembled from tiles: the bytes rfc9162::inclusion_proof gives over the flat leaf slice. Nothing for an index past the size.

Source

pub fn consistency_proof(&self, old: u64) -> Result<Option<Vec<Hash>>>

The consistency proof that the tree of old leaves is a prefix of this one, RFC 9162 section 2.1.4, assembled from tiles: the bytes rfc9162::consistency_proof gives over the flat leaf slice. Nothing when old is zero or past the size.

Auto Trait Implementations§

§

impl<S> !Freeze for TileHashReader<S>

§

impl<S> !RefUnwindSafe for TileHashReader<S>

§

impl<S> !Send for TileHashReader<S>

§

impl<S> !Sync for TileHashReader<S>

§

impl<S> Unpin for TileHashReader<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for TileHashReader<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for TileHashReader<S>
where S: UnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.