Add methods for getting block nullifiers (#2465)
* Add methods for getting block nullifiers These methods will be used in a future PR to check for double-spends. * Add doc links Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com> Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
This commit is contained in:
parent
d4cc867132
commit
14d5abdb03
|
@ -29,8 +29,11 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use crate::{
|
||||
fmt::DisplayToDebug,
|
||||
orchard,
|
||||
parameters::{Network, NetworkUpgrade},
|
||||
sapling,
|
||||
serialization::{TrustedPreallocate, MAX_PROTOCOL_MESSAGE_LEN},
|
||||
sprout,
|
||||
transaction::Transaction,
|
||||
transparent,
|
||||
};
|
||||
|
@ -116,6 +119,30 @@ impl Block {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Access the [`sprout::Nullifier`]s from all transactions in this block.
|
||||
pub fn sprout_nullifiers(&self) -> impl Iterator<Item = &sprout::Nullifier> {
|
||||
self.transactions
|
||||
.iter()
|
||||
.map(|transaction| transaction.sprout_nullifiers())
|
||||
.flatten()
|
||||
}
|
||||
|
||||
/// Access the [`sapling::Nullifier`]s from all transactions in this block.
|
||||
pub fn sapling_nullifiers(&self) -> impl Iterator<Item = &sapling::Nullifier> {
|
||||
self.transactions
|
||||
.iter()
|
||||
.map(|transaction| transaction.sapling_nullifiers())
|
||||
.flatten()
|
||||
}
|
||||
|
||||
/// Access the [`orchard::Nullifier`]s from all transactions in this block.
|
||||
pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &orchard::Nullifier> {
|
||||
self.transactions
|
||||
.iter()
|
||||
.map(|transaction| transaction.orchard_nullifiers())
|
||||
.flatten()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Block> for Hash {
|
||||
|
|
Loading…
Reference in New Issue