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:
teor 2021-07-09 12:54:57 +10:00 committed by GitHub
parent d4cc867132
commit 14d5abdb03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

View File

@ -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 {