Rename SpendDescription to Spend, OutputDescription to Output

This commit is contained in:
Deirdre Connolly 2020-04-09 15:50:31 -04:00 committed by Deirdre Connolly
parent 680ec5fae4
commit 955a4ebc3c
3 changed files with 24 additions and 24 deletions

View File

@ -13,7 +13,7 @@ mod tests;
pub use hash::TransactionHash; pub use hash::TransactionHash;
pub use joinsplit::{JoinSplit, JoinSplitData}; pub use joinsplit::{JoinSplit, JoinSplitData};
pub use shielded_data::{OutputDescription, ShieldedData, SpendDescription}; pub use shielded_data::{Output, ShieldedData, Spend};
pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput}; pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput};
use crate::proofs::{Bctv14Proof, Groth16Proof}; use crate::proofs::{Bctv14Proof, Groth16Proof};

View File

@ -302,7 +302,7 @@ impl<P: ZkSnarkProof> ZcashDeserialize for Option<JoinSplitData<P>> {
} }
} }
impl ZcashSerialize for SpendDescription { impl ZcashSerialize for Spend {
fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> { fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
writer.write_all(&self.cv[..])?; writer.write_all(&self.cv[..])?;
writer.write_all(&self.anchor.0[..])?; writer.write_all(&self.anchor.0[..])?;
@ -314,10 +314,10 @@ impl ZcashSerialize for SpendDescription {
} }
} }
impl ZcashDeserialize for SpendDescription { impl ZcashDeserialize for Spend {
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> { fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
use crate::note_commitment_tree::SaplingNoteTreeRootHash; use crate::note_commitment_tree::SaplingNoteTreeRootHash;
Ok(SpendDescription { Ok(Spend {
cv: reader.read_32_bytes()?, cv: reader.read_32_bytes()?,
anchor: SaplingNoteTreeRootHash(reader.read_32_bytes()?), anchor: SaplingNoteTreeRootHash(reader.read_32_bytes()?),
nullifier: reader.read_32_bytes()?, nullifier: reader.read_32_bytes()?,
@ -328,7 +328,7 @@ impl ZcashDeserialize for SpendDescription {
} }
} }
impl ZcashSerialize for OutputDescription { impl ZcashSerialize for Output {
fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> { fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
writer.write_all(&self.cv[..])?; writer.write_all(&self.cv[..])?;
writer.write_all(&self.cmu[..])?; writer.write_all(&self.cmu[..])?;
@ -340,9 +340,9 @@ impl ZcashSerialize for OutputDescription {
} }
} }
impl ZcashDeserialize for OutputDescription { impl ZcashDeserialize for Output {
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> { fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
Ok(OutputDescription { Ok(Output {
cv: reader.read_32_bytes()?, cv: reader.read_32_bytes()?,
cmu: reader.read_32_bytes()?, cmu: reader.read_32_bytes()?,
ephemeral_key: reader.read_32_bytes()?, ephemeral_key: reader.read_32_bytes()?,

View File

@ -18,7 +18,7 @@ use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize}
/// ///
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#spendencoding /// [ps]: https://zips.z.cash/protocol/protocol.pdf#spendencoding
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct SpendDescription { pub struct Spend {
/// A value commitment to the value of the input note. /// A value commitment to the value of the input note.
/// ///
/// XXX refine to a specific type. /// XXX refine to a specific type.
@ -38,7 +38,7 @@ pub struct SpendDescription {
} }
#[cfg(test)] #[cfg(test)]
impl Arbitrary for SpendDescription { impl Arbitrary for Spend {
type Parameters = (); type Parameters = ();
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
@ -77,7 +77,7 @@ impl Arbitrary for SpendDescription {
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#outputencoding /// [ps]: https://zips.z.cash/protocol/protocol.pdf#outputencoding
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(test, derive(Arbitrary))] #[cfg_attr(test, derive(Arbitrary))]
pub struct OutputDescription { pub struct Output {
/// A value commitment to the value of the input note. /// A value commitment to the value of the input note.
/// ///
/// XXX refine to a specific type. /// XXX refine to a specific type.
@ -109,25 +109,25 @@ pub struct ShieldedData {
/// However, it's not necessary to access or process `first` and `rest` /// However, it's not necessary to access or process `first` and `rest`
/// separately, as the [`ShieldedData::spends`] and [`ShieldedData::outputs`] /// separately, as the [`ShieldedData::spends`] and [`ShieldedData::outputs`]
/// methods provide iterators over all of the [`SpendDescription`]s and /// methods provide iterators over all of the [`SpendDescription`]s and
/// [`OutputDescription`]s. /// [`Output`]s.
pub first: Either<SpendDescription, OutputDescription>, pub first: Either<Spend, Output>,
/// The rest of the [`SpendDescription`]s for this transaction. /// The rest of the [`Spend`]s for this transaction.
/// ///
/// Note that the [`ShieldedData::spends`] method provides an iterator /// Note that the [`ShieldedData::spends`] method provides an iterator
/// over all spend descriptions. /// over all spend descriptions.
pub rest_spends: Vec<SpendDescription>, pub rest_spends: Vec<Spend>,
/// The rest of the [`OutputDescription`]s for this transaction. /// The rest of the [`Output`]s for this transaction.
/// ///
/// Note that the [`ShieldedData::outputs`] method provides an iterator /// Note that the [`ShieldedData::outputs`] method provides an iterator
/// over all output descriptions. /// over all output descriptions.
pub rest_outputs: Vec<OutputDescription>, pub rest_outputs: Vec<Output>,
/// A signature on the transaction hash. /// A signature on the transaction hash.
pub binding_sig: redjubjub::Signature<Binding>, pub binding_sig: redjubjub::Signature<Binding>,
} }
impl ShieldedData { impl ShieldedData {
/// Iterate over the [`SpendDescription`]s for this transaction. /// Iterate over the [`Spend`]s for this transaction.
pub fn spends(&self) -> impl Iterator<Item = &SpendDescription> { pub fn spends(&self) -> impl Iterator<Item = &Spend> {
match self.first { match self.first {
Either::Left(ref spend) => Some(spend), Either::Left(ref spend) => Some(spend),
Either::Right(_) => None, Either::Right(_) => None,
@ -136,8 +136,8 @@ impl ShieldedData {
.chain(self.rest_spends.iter()) .chain(self.rest_spends.iter())
} }
/// Iterate over the [`OutputDescription`]s for this transaction. /// Iterate over the [`Output`]s for this transaction.
pub fn outputs(&self) -> impl Iterator<Item = &OutputDescription> { pub fn outputs(&self) -> impl Iterator<Item = &Output> {
match self.first { match self.first {
Either::Left(_) => None, Either::Left(_) => None,
Either::Right(ref output) => Some(output), Either::Right(ref output) => Some(output),
@ -179,11 +179,11 @@ impl Arbitrary for ShieldedData {
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
( (
prop_oneof![ prop_oneof![
any::<SpendDescription>().prop_map(Either::Left), any::<Spend>().prop_map(Either::Left),
any::<OutputDescription>().prop_map(Either::Right) any::<Output>().prop_map(Either::Right)
], ],
vec(any::<SpendDescription>(), 0..10), vec(any::<Spend>(), 0..10),
vec(any::<OutputDescription>(), 0..10), vec(any::<Output>(), 0..10),
vec(any::<u8>(), 64), vec(any::<u8>(), 64),
) )
.prop_map(|(first, rest_spends, rest_outputs, sig_bytes)| { .prop_map(|(first, rest_spends, rest_outputs, sig_bytes)| {