pub trait QueryablePayload<Types: NodeType>: BlockPayload<Types>where
Header<Types>: QueryableHeader<Types>,{
type Iter<'a>: Iterator<Item = TransactionIndex<Types>>
where Self: 'a;
type InclusionProof: Clone + Debug + PartialEq + Eq + Serialize + DeserializeOwned + Send + Sync;
// Required methods
fn len(&self, meta: &Self::Metadata) -> usize;
fn iter<'a>(&'a self, meta: &'a Self::Metadata) -> Self::Iter<'a>;
fn transaction(
&self,
meta: &Self::Metadata,
index: &TransactionIndex<Types>,
) -> Option<Self::Transaction>;
fn transaction_proof(
&self,
meta: &Self::Metadata,
vid: &VidCommonQueryData<Types>,
index: &TransactionIndex<Types>,
) -> Option<Self::InclusionProof>;
// Provided methods
fn is_empty(&self, meta: &Self::Metadata) -> bool { ... }
fn enumerate<'a>(
&'a self,
meta: &'a Self::Metadata,
) -> Box<dyn Iterator<Item = (TransactionIndex<Types>, Self::Transaction)> + 'a> { ... }
fn nth(
&self,
meta: &Self::Metadata,
n: usize,
) -> Option<TransactionIndex<Types>> { ... }
fn nth_transaction(
&self,
meta: &Self::Metadata,
n: usize,
) -> Option<Self::Transaction> { ... }
fn by_hash(
&self,
meta: &Self::Metadata,
hash: Commitment<Self::Transaction>,
) -> Option<TransactionIndex<Types>> { ... }
fn transaction_by_hash(
&self,
meta: &Self::Metadata,
hash: Commitment<Self::Transaction>,
) -> Option<Self::Transaction> { ... }
}
Expand description
A block payload whose contents (e.g. individual transactions) can be examined.
Note to implementers: this trait has only a few required methods. The provided methods, for
querying transactions in various ways, are implemented in terms of the required
iter
and transaction_proof
methods, and
the default implementations may be inefficient (e.g. performing an O(n) search, or computing an
unnecessary inclusion proof). It is good practice to override these default implementations if
your block type supports more efficient implementations (e.g. sublinear indexing by hash).
Required Associated Types§
Sourcetype Iter<'a>: Iterator<Item = TransactionIndex<Types>>
where
Self: 'a
type Iter<'a>: Iterator<Item = TransactionIndex<Types>> where Self: 'a
Enumerate the transactions in this block.
Sourcetype InclusionProof: Clone + Debug + PartialEq + Eq + Serialize + DeserializeOwned + Send + Sync
type InclusionProof: Clone + Debug + PartialEq + Eq + Serialize + DeserializeOwned + Send + Sync
A proof that a certain transaction exists in the block.
The proof system and the statement which is proved will vary by application, with different
applications proving stronger or weaker statements depending on the trust assumptions at
play. Some may prove a very strong statement (for example, a shared sequencer proving that
the transaction belongs not only to the block but to a section of the block dedicated to a
specific rollup), otherwise may prove something substantially weaker (for example, a trusted
query service may use ()
for the proof).
Required Methods§
Sourcefn iter<'a>(&'a self, meta: &'a Self::Metadata) -> Self::Iter<'a>
fn iter<'a>(&'a self, meta: &'a Self::Metadata) -> Self::Iter<'a>
List the transaction indices in the block.
Sourcefn transaction(
&self,
meta: &Self::Metadata,
index: &TransactionIndex<Types>,
) -> Option<Self::Transaction>
fn transaction( &self, meta: &Self::Metadata, index: &TransactionIndex<Types>, ) -> Option<Self::Transaction>
Get a transaction by its block-specific index.
Sourcefn transaction_proof(
&self,
meta: &Self::Metadata,
vid: &VidCommonQueryData<Types>,
index: &TransactionIndex<Types>,
) -> Option<Self::InclusionProof>
fn transaction_proof( &self, meta: &Self::Metadata, vid: &VidCommonQueryData<Types>, index: &TransactionIndex<Types>, ) -> Option<Self::InclusionProof>
Get an inclusion proof for the given transaction.
This function may be slow and computationally intensive, especially for large transactions.
Provided Methods§
Sourcefn enumerate<'a>(
&'a self,
meta: &'a Self::Metadata,
) -> Box<dyn Iterator<Item = (TransactionIndex<Types>, Self::Transaction)> + 'a>
fn enumerate<'a>( &'a self, meta: &'a Self::Metadata, ) -> Box<dyn Iterator<Item = (TransactionIndex<Types>, Self::Transaction)> + 'a>
Enumerate the transactions in the block with their indices.
Sourcefn nth(
&self,
meta: &Self::Metadata,
n: usize,
) -> Option<TransactionIndex<Types>>
fn nth( &self, meta: &Self::Metadata, n: usize, ) -> Option<TransactionIndex<Types>>
Get the index of the nth
transaction.
Sourcefn nth_transaction(
&self,
meta: &Self::Metadata,
n: usize,
) -> Option<Self::Transaction>
fn nth_transaction( &self, meta: &Self::Metadata, n: usize, ) -> Option<Self::Transaction>
Get the nth
transaction.
Sourcefn by_hash(
&self,
meta: &Self::Metadata,
hash: Commitment<Self::Transaction>,
) -> Option<TransactionIndex<Types>>
fn by_hash( &self, meta: &Self::Metadata, hash: Commitment<Self::Transaction>, ) -> Option<TransactionIndex<Types>>
Get the index of the transaction with a given hash, if it is in the block.
Sourcefn transaction_by_hash(
&self,
meta: &Self::Metadata,
hash: Commitment<Self::Transaction>,
) -> Option<Self::Transaction>
fn transaction_by_hash( &self, meta: &Self::Metadata, hash: Commitment<Self::Transaction>, ) -> Option<Self::Transaction>
Get the transaction with a given hash, if it is in the block.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.