Use more informative type names in Extension trait.
This commit is contained in:
parent
36c28341b3
commit
6a536aa88a
|
@ -1,7 +1,7 @@
|
|||
//! Consensus logic for Transparent Zcash Extensions.
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use zcash_primitives::consensus::NetworkUpgrade;
|
||||
use zcash_primitives::consensus::{BlockHeight, NetworkUpgrade};
|
||||
use zcash_primitives::extensions::transparent::{Error, Extension, Precondition, Witness};
|
||||
use zcash_primitives::transaction::{components::TzeOut, Transaction};
|
||||
|
||||
|
@ -41,12 +41,12 @@ impl From<ExtensionId> for u32 {
|
|||
/// an assigned extension type ID. This type may be modified in the future if
|
||||
/// additional context information is required by newly integrated TZEs.
|
||||
pub struct Context<'a> {
|
||||
pub height: i32,
|
||||
pub height: BlockHeight,
|
||||
pub tx: &'a Transaction,
|
||||
}
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
pub fn new(height: i32, tx: &'a Transaction) -> Self {
|
||||
pub fn new(height: BlockHeight, tx: &'a Transaction) -> Self {
|
||||
Context { height, tx }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,8 +249,8 @@ pub trait Context {
|
|||
pub struct Program;
|
||||
|
||||
impl<C: Context> Extension<C> for Program {
|
||||
type P = Precondition;
|
||||
type W = Witness;
|
||||
type Precondition = Precondition;
|
||||
type Witness = Witness;
|
||||
type Error = Error;
|
||||
|
||||
/// Runs the program against the given precondition, witness, and context.
|
||||
|
|
|
@ -116,12 +116,12 @@ pub trait Extension<C> {
|
|||
/// Extension-specific precondition type. The extension will need to implement
|
||||
/// [`FromPayload<Error = Self::Error>`] for this type in order for their
|
||||
/// extension to be eligible for integration into consensus rules.
|
||||
type P;
|
||||
type Precondition;
|
||||
|
||||
/// Extension-specific witness type. The extension will need to implement
|
||||
/// [`FromPayload<Error = Self::Error>`] for this type in order for their
|
||||
/// extension to be eligible for integration into consensus rules.
|
||||
type W;
|
||||
type Witness;
|
||||
|
||||
/// Extension-specific error type. This should encompass both parsing and verification errors.
|
||||
type Error;
|
||||
|
@ -131,8 +131,8 @@ pub trait Extension<C> {
|
|||
/// precondition, and an error in any other case.
|
||||
fn verify_inner(
|
||||
&self,
|
||||
precondition: &Self::P,
|
||||
witness: &Self::W,
|
||||
precondition: &Self::Precondition,
|
||||
witness: &Self::Witness,
|
||||
context: &C,
|
||||
) -> Result<(), Self::Error>;
|
||||
|
||||
|
@ -146,12 +146,12 @@ pub trait Extension<C> {
|
|||
context: &C,
|
||||
) -> Result<(), Self::Error>
|
||||
where
|
||||
Self::P: FromPayload<Error = Self::Error>,
|
||||
Self::W: FromPayload<Error = Self::Error>,
|
||||
Self::Precondition: FromPayload<Error = Self::Error>,
|
||||
Self::Witness: FromPayload<Error = Self::Error>,
|
||||
{
|
||||
self.verify_inner(
|
||||
&Self::P::from_payload(precondition.mode, &precondition.payload)?,
|
||||
&Self::W::from_payload(witness.mode, &witness.payload)?,
|
||||
&Self::Precondition::from_payload(precondition.mode, &precondition.payload)?,
|
||||
&Self::Witness::from_payload(witness.mode, &witness.payload)?,
|
||||
&context,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue