mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Removing verifier caches (#3597)
This commit is contained in:
parent
6690b25f05
commit
87ff219d37
1 changed files with 4 additions and 23 deletions
|
@ -1246,42 +1246,23 @@ impl TransactionBody {
|
||||||
pub fn validate(
|
pub fn validate(
|
||||||
&self,
|
&self,
|
||||||
weighting: Weighting,
|
weighting: Weighting,
|
||||||
verifier: Arc<RwLock<dyn VerifierCache>>,
|
_verifier: Arc<RwLock<dyn VerifierCache>>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.validate_read(weighting)?;
|
self.validate_read(weighting)?;
|
||||||
|
|
||||||
// Find all the outputs that have not had their rangeproofs verified.
|
|
||||||
let outputs = {
|
|
||||||
let mut verifier = verifier.write();
|
|
||||||
verifier.filter_rangeproof_unverified(&self.outputs)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Now batch verify all those unverified rangeproofs
|
// Now batch verify all those unverified rangeproofs
|
||||||
if !outputs.is_empty() {
|
if !self.outputs.is_empty() {
|
||||||
let mut commits = vec![];
|
let mut commits = vec![];
|
||||||
let mut proofs = vec![];
|
let mut proofs = vec![];
|
||||||
for x in &outputs {
|
for x in &self.outputs {
|
||||||
commits.push(x.commitment());
|
commits.push(x.commitment());
|
||||||
proofs.push(x.proof);
|
proofs.push(x.proof);
|
||||||
}
|
}
|
||||||
Output::batch_verify_proofs(&commits, &proofs)?;
|
Output::batch_verify_proofs(&commits, &proofs)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find all the kernels that have not yet been verified.
|
|
||||||
let kernels = {
|
|
||||||
let mut verifier = verifier.write();
|
|
||||||
verifier.filter_kernel_sig_unverified(&self.kernels)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Verify the unverified tx kernels.
|
// Verify the unverified tx kernels.
|
||||||
TxKernel::batch_sig_verify(&kernels)?;
|
TxKernel::batch_sig_verify(&self.kernels)?;
|
||||||
|
|
||||||
// Cache the successful verification results for the new outputs and kernels.
|
|
||||||
{
|
|
||||||
let mut verifier = verifier.write();
|
|
||||||
verifier.add_rangeproof_verified(outputs);
|
|
||||||
verifier.add_kernel_sig_verified(kernels);
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue