pub struct DataAvailabilityHeader { /* private fields */ }Expand description
Header with commitments of the data availability.
It consists of the root hashes of the merkle trees created from each
row and column of the ExtendedDataSquare. Those are used to prove
the inclusion of the data in a block.
The hash of this header is a hash of all rows and columns and thus a data commitment of the block.
§Example
// fetch the block header and data for your namespace
let namespace = Namespace::new_v0(&[1, 2, 3, 4]).unwrap();
let eh = extended_header();
let (shares, proof) = shares_with_proof(eh.height(), &namespace);
// get the data commitment for a given row
let dah = eh.dah;
let root = dah.row_root(0).unwrap();
// verify a proof of the inclusion of the shares
assert!(proof.verify_complete_namespace(&root, &shares, *namespace).is_ok());Implementations§
Source§impl DataAvailabilityHeader
impl DataAvailabilityHeader
Sourcepub fn new(
row_roots: Vec<NamespacedHash>,
column_roots: Vec<NamespacedHash>,
app_version: AppVersion,
) -> Result<Self>
pub fn new( row_roots: Vec<NamespacedHash>, column_roots: Vec<NamespacedHash>, app_version: AppVersion, ) -> Result<Self>
Create new DataAvailabilityHeader.
Sourcepub fn new_unchecked(
row_roots: Vec<NamespacedHash>,
column_roots: Vec<NamespacedHash>,
) -> Self
pub fn new_unchecked( row_roots: Vec<NamespacedHash>, column_roots: Vec<NamespacedHash>, ) -> Self
Create new non-validated DataAvailabilityHeader.
DataAvailabilityHeader::validate_basic can be used to check valitidy later on.
Sourcepub fn from_eds(eds: &ExtendedDataSquare) -> Self
pub fn from_eds(eds: &ExtendedDataSquare) -> Self
Create a DataAvailabilityHeader by computing roots of a given ExtendedDataSquare.
Sourcepub fn root(&self, axis: AxisType, index: u16) -> Option<NamespacedHash>
pub fn root(&self, axis: AxisType, index: u16) -> Option<NamespacedHash>
Get the root from an axis at the given index.
Sourcepub fn row_roots(&self) -> &[NamespacedHash] ⓘ
pub fn row_roots(&self) -> &[NamespacedHash] ⓘ
Merkle roots of the ExtendedDataSquare rows.
Sourcepub fn column_roots(&self) -> &[NamespacedHash] ⓘ
pub fn column_roots(&self) -> &[NamespacedHash] ⓘ
Merkle roots of the ExtendedDataSquare columns.
Sourcepub fn row_root(&self, row: u16) -> Option<NamespacedHash>
pub fn row_root(&self, row: u16) -> Option<NamespacedHash>
Get a root of the row with the given index.
Sourcepub fn column_root(&self, column: u16) -> Option<NamespacedHash>
pub fn column_root(&self, column: u16) -> Option<NamespacedHash>
Get the a root of the column with the given index.
Sourcepub fn hash(&self) -> Hash
pub fn hash(&self) -> Hash
Compute the combined hash of all rows and columns.
This is the data commitment for the block.
§Example
let eh = get_extended_header();
let dah = eh.dah;
assert_eq!(dah.hash(), eh.header.data_hash.unwrap());Sourcepub fn square_width(&self) -> u16
pub fn square_width(&self) -> u16
Get the size of the ExtendedDataSquare for which this header was built.
Trait Implementations§
Source§impl Clone for DataAvailabilityHeader
impl Clone for DataAvailabilityHeader
Source§fn clone(&self) -> DataAvailabilityHeader
fn clone(&self) -> DataAvailabilityHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DataAvailabilityHeader
impl Debug for DataAvailabilityHeader
Source§impl<'de> Deserialize<'de> for DataAvailabilityHeader
impl<'de> Deserialize<'de> for DataAvailabilityHeader
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<DataAvailabilityHeader> for DataAvailabilityHeader
impl From<DataAvailabilityHeader> for DataAvailabilityHeader
Source§fn from(value: DataAvailabilityHeader) -> RawDataAvailabilityHeader
fn from(value: DataAvailabilityHeader) -> RawDataAvailabilityHeader
Source§impl PartialEq for DataAvailabilityHeader
impl PartialEq for DataAvailabilityHeader
Source§impl Protobuf<DataAvailabilityHeader> for DataAvailabilityHeader
impl Protobuf<DataAvailabilityHeader> for DataAvailabilityHeader
Source§fn encode<B>(self, buf: &mut B) -> Result<(), Error>where
B: BufMut,
fn encode<B>(self, buf: &mut B) -> Result<(), Error>where
B: BufMut,
Source§fn encode_length_delimited<B>(self, buf: &mut B) -> Result<(), Error>where
B: BufMut,
fn encode_length_delimited<B>(self, buf: &mut B) -> Result<(), Error>where
B: BufMut,
Source§fn decode<B>(buf: B) -> Result<Self, Error>where
B: Buf,
fn decode<B>(buf: B) -> Result<Self, Error>where
B: Buf,
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, Error>where
B: Buf,
fn decode_length_delimited<B>(buf: B) -> Result<Self, Error>where
B: Buf,
Source§fn encoded_len(self) -> usize
fn encoded_len(self) -> usize
Source§fn decode_vec(v: &[u8]) -> Result<Self, Error>
fn decode_vec(v: &[u8]) -> Result<Self, Error>
Vec<u8> (or equivalent).Source§impl Serialize for DataAvailabilityHeader
impl Serialize for DataAvailabilityHeader
Source§impl ValidateBasicWithAppVersion for DataAvailabilityHeader
impl ValidateBasicWithAppVersion for DataAvailabilityHeader
Source§fn validate_basic(&self, app_version: AppVersion) -> Result<(), ValidationError>
fn validate_basic(&self, app_version: AppVersion) -> Result<(), ValidationError>
impl Eq for DataAvailabilityHeader
impl StructuralPartialEq for DataAvailabilityHeader
Auto Trait Implementations§
impl Freeze for DataAvailabilityHeader
impl RefUnwindSafe for DataAvailabilityHeader
impl Send for DataAvailabilityHeader
impl Sync for DataAvailabilityHeader
impl Unpin for DataAvailabilityHeader
impl UnwindSafe for DataAvailabilityHeader
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.