forked from zcash/orchard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Porting Batch Validator changes on top of the latest version of zsa1 …
…branch (after PR #81 was merged)
- Loading branch information
Showing
5 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::collections::HashSet; | ||
|
||
use super::{verify_issue_bundle, AssetBase, IssueBundle, Signed}; | ||
|
||
/// Batch validation context for Issuance. | ||
/// | ||
#[derive(Debug, Default)] | ||
pub struct BatchValidator { | ||
bundles: Vec<(IssueBundle<Signed>, [u8; 32])>, | ||
} | ||
|
||
impl BatchValidator { | ||
/// Constructs a new batch validation context. | ||
pub fn new() -> Self { | ||
BatchValidator { bundles: vec![] } | ||
} | ||
|
||
/// Adds bundle to the validator. | ||
pub fn add_bundle(&mut self, bundle: &IssueBundle<Signed>, sighash: [u8; 32]) { | ||
self.bundles.push((bundle.clone(), sighash)) | ||
} | ||
|
||
/// Batch-validates the accumulated bundles. | ||
/// | ||
/// Returns `true` if every bundle added to the batch validator is valid, or `false` | ||
/// if one or more are invalid. | ||
pub fn validate(self) -> bool { | ||
// FIXME: take/save finalization set from/to the global state | ||
let finalized = HashSet::<AssetBase>::new(); | ||
|
||
// FIXME: process resulting supply_info | ||
self.bundles | ||
.into_iter() | ||
.all(|(bundle, sighash)| verify_issue_bundle(&bundle, sighash, &finalized).is_ok()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters