Struct celestia_types::DataAvailabilityHeader
source · pub struct DataAvailabilityHeader {
pub row_roots: Vec<NamespacedHash>,
pub column_roots: Vec<NamespacedHash>,
}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());Fields§
§row_roots: Vec<NamespacedHash>Merkle roots of the ExtendedDataSquare rows.
column_roots: Vec<NamespacedHash>Merkle roots of the ExtendedDataSquare columns.
Implementations§
source§impl DataAvailabilityHeader
impl DataAvailabilityHeader
sourcepub fn root(&self, axis: AxisType, index: usize) -> Option<NamespacedHash>
pub fn root(&self, axis: AxisType, index: usize) -> Option<NamespacedHash>
Get the root from an axis at the given index.
sourcepub fn row_root(&self, row: usize) -> Option<NamespacedHash>
pub fn row_root(&self, row: usize) -> Option<NamespacedHash>
Get a root of the row with the given index.
sourcepub fn column_root(&self, column: usize) -> Option<NamespacedHash>
pub fn column_root(&self, column: usize) -> 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);sourcepub fn square_len(&self) -> usize
pub fn square_len(&self) -> usize
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
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<DataAvailabilityHeader> for DataAvailabilityHeader
impl From<DataAvailabilityHeader> for DataAvailabilityHeader
source§fn from(value: DataAvailabilityHeader) -> RawDataAvailabilityHeader
fn from(value: DataAvailabilityHeader) -> RawDataAvailabilityHeader
Converts to this type from the input type.
source§impl PartialEq for DataAvailabilityHeader
impl PartialEq for DataAvailabilityHeader
source§fn eq(&self, other: &DataAvailabilityHeader) -> bool
fn eq(&self, other: &DataAvailabilityHeader) -> bool
This method tests for
self and other values to be equal, and is used
by ==.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,
Encode into a buffer in Protobuf format. Read more
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,
Encode with a length-delimiter to a buffer in Protobuf format. Read more
source§fn decode<B>(buf: B) -> Result<Self, Error>where
B: Buf,
fn decode<B>(buf: B) -> Result<Self, Error>where
B: Buf,
Constructor that attempts to decode an instance from a buffer. Read more
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,
Constructor that attempts to decode a length-delimited instance from
the buffer. Read more
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter. Read more
source§fn encode_vec(&self) -> Result<Vec<u8>, Infallible>
fn encode_vec(&self) -> Result<Vec<u8>, Infallible>
Encodes into a Protobuf-encoded
Vec<u8>.source§fn decode_vec(v: &[u8]) -> Result<Self, Error>
fn decode_vec(v: &[u8]) -> Result<Self, Error>
Constructor that attempts to decode a Protobuf-encoded instance from a
Vec<u8> (or equivalent).source§fn encode_length_delimited_vec(&self) -> Result<Vec<u8>, Infallible>
fn encode_length_delimited_vec(&self) -> Result<Vec<u8>, Infallible>
Encode with a length-delimiter to a
Vec<u8> Protobuf-encoded message.source§impl Serialize for DataAvailabilityHeader
impl Serialize for DataAvailabilityHeader
source§impl ValidateBasic for DataAvailabilityHeader
impl ValidateBasic for DataAvailabilityHeader
source§fn validate_basic(&self) -> Result<(), ValidationError>
fn validate_basic(&self) -> Result<(), ValidationError>
Perform a basic validation of the data consistency.
impl Eq for DataAvailabilityHeader
impl StructuralEq for DataAvailabilityHeader
impl StructuralPartialEq for DataAvailabilityHeader
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more