From 6a536aa88af8d927c3cc7c56717ee6f3a4dd32cf Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 23 Sep 2020 13:35:14 -0600 Subject: [PATCH] Use more informative type names in Extension trait. --- zcash_extensions/src/consensus/transparent.rs | 6 +++--- zcash_extensions/src/transparent/demo.rs | 4 ++-- zcash_primitives/src/extensions/transparent.rs | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/zcash_extensions/src/consensus/transparent.rs b/zcash_extensions/src/consensus/transparent.rs index bc274cf2a..012df3b69 100644 --- a/zcash_extensions/src/consensus/transparent.rs +++ b/zcash_extensions/src/consensus/transparent.rs @@ -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 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 } } } diff --git a/zcash_extensions/src/transparent/demo.rs b/zcash_extensions/src/transparent/demo.rs index 8753c272d..9b15c7201 100644 --- a/zcash_extensions/src/transparent/demo.rs +++ b/zcash_extensions/src/transparent/demo.rs @@ -249,8 +249,8 @@ pub trait Context { pub struct Program; impl Extension 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. diff --git a/zcash_primitives/src/extensions/transparent.rs b/zcash_primitives/src/extensions/transparent.rs index aea2eac55..4fd18ab2f 100644 --- a/zcash_primitives/src/extensions/transparent.rs +++ b/zcash_primitives/src/extensions/transparent.rs @@ -116,12 +116,12 @@ pub trait Extension { /// Extension-specific precondition type. The extension will need to implement /// [`FromPayload`] 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`] 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 { /// 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 { context: &C, ) -> Result<(), Self::Error> where - Self::P: FromPayload, - Self::W: FromPayload, + Self::Precondition: FromPayload, + Self::Witness: FromPayload, { 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, ) }