chain: move amount to a top-level module.

This commit is contained in:
Henry de Valence 2020-08-14 23:15:36 -07:00
parent cee7d0b8eb
commit a35604aef3
11 changed files with 14 additions and 15 deletions

View File

@ -1,4 +1,5 @@
//! Module of types for working with validated zatoshi Amounts //! Strongly-typed zatoshi amounts that prevent under/overflows.
use std::{ use std::{
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
marker::PhantomData, marker::PhantomData,

View File

@ -13,11 +13,11 @@ use bitvec::prelude::*;
use rand_core::{CryptoRng, RngCore}; use rand_core::{CryptoRng, RngCore};
use crate::{ use crate::{
amount::{Amount, NonNegative},
keys::sapling::{find_group_hash, Diversifier, TransmissionKey}, keys::sapling::{find_group_hash, Diversifier, TransmissionKey},
serialization::{ serialization::{
serde_helpers, ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize, serde_helpers, ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize,
}, },
types::amount::{Amount, NonNegative},
}; };
use pedersen_hashes::*; use pedersen_hashes::*;

View File

@ -14,6 +14,7 @@ extern crate serde;
mod merkle_tree; mod merkle_tree;
pub mod addresses; pub mod addresses;
pub mod amount;
pub mod block; pub mod block;
pub mod commitments; pub mod commitments;
pub mod equihash_solution; pub mod equihash_solution;

View File

@ -9,10 +9,10 @@ mod ciphertexts;
mod nullifiers; mod nullifiers;
use crate::{ use crate::{
amount::{Amount, NonNegative},
commitments::sapling::CommitmentRandomness, commitments::sapling::CommitmentRandomness,
keys::sapling::{Diversifier, TransmissionKey}, keys::sapling::{Diversifier, TransmissionKey},
notes::memo::Memo, notes::memo::Memo,
types::amount::{Amount, NonNegative},
}; };
pub use ciphertexts::{EncryptedCiphertext, OutCiphertext}; pub use ciphertexts::{EncryptedCiphertext, OutCiphertext};

View File

@ -9,10 +9,10 @@ mod ciphertexts;
mod nullifiers; mod nullifiers;
use crate::{ use crate::{
amount::{Amount, NonNegative},
commitments::sprout::CommitmentRandomness, commitments::sprout::CommitmentRandomness,
keys::sprout::PayingKey, keys::sprout::PayingKey,
notes::memo::Memo, notes::memo::Memo,
types::amount::{Amount, NonNegative},
}; };
pub use ciphertexts::EncryptedCiphertext; pub use ciphertexts::EncryptedCiphertext;

View File

@ -18,6 +18,6 @@ pub enum SerializationError {
Amount { Amount {
/// The source error indicating how the num failed to validate /// The source error indicating how the num failed to validate
#[from] #[from]
source: crate::types::amount::Error, source: crate::amount::Error,
}, },
} }

View File

@ -16,8 +16,9 @@ pub use joinsplit::{JoinSplit, JoinSplitData};
pub use shielded_data::{Output, ShieldedData, Spend}; pub use shielded_data::{Output, ShieldedData, Spend};
pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput}; pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput};
use crate::amount::Amount;
use crate::proofs::{Bctv14Proof, Groth16Proof}; use crate::proofs::{Bctv14Proof, Groth16Proof};
use crate::types::{amount::Amount, BlockHeight, LockTime}; use crate::types::{BlockHeight, LockTime};
/// A Zcash transaction. /// A Zcash transaction.
/// ///

View File

@ -1,11 +1,11 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
amount::{Amount, NonNegative},
ed25519_zebra, ed25519_zebra,
notes::sprout, notes::sprout,
proofs::ZkSnarkProof, proofs::ZkSnarkProof,
treestate, treestate,
types::amount::{Amount, NonNegative},
}; };
/// A _JoinSplit Description_, as described in [protocol specification §7.2][ps]. /// A _JoinSplit Description_, as described in [protocol specification §7.2][ps].

View File

@ -1,4 +1,5 @@
use crate::{ use crate::{
amount::{Amount, NonNegative},
commitments, keys, commitments, keys,
notes::{sapling, sprout}, notes::{sapling, sprout},
proofs::{Groth16Proof, ZkSnarkProof}, proofs::{Groth16Proof, ZkSnarkProof},
@ -7,10 +8,7 @@ use crate::{
TransparentInput, TransparentInput,
}, },
treestate::{self, note_commitment_tree::SaplingNoteTreeRootHash}, treestate::{self, note_commitment_tree::SaplingNoteTreeRootHash},
types::{ types::{BlockHeight, Script},
amount::{Amount, NonNegative},
BlockHeight, Script,
},
}; };
use futures::future::Either; use futures::future::Either;
use proptest::{array, collection::vec, prelude::*}; use proptest::{array, collection::vec, prelude::*};

View File

@ -4,9 +4,9 @@
#[cfg(test)] #[cfg(test)]
use proptest_derive::Arbitrary; use proptest_derive::Arbitrary;
use crate::types::{ use crate::{
amount::{Amount, NonNegative}, amount::{Amount, NonNegative},
BlockHeight, Script, types::{BlockHeight, Script},
}; };
use super::TransactionHash; use super::TransactionHash;

View File

@ -10,8 +10,6 @@ use std::{
io::{self, Read}, io::{self, Read},
}; };
pub mod amount;
/// A u32 which represents a block height value. /// A u32 which represents a block height value.
/// ///
/// # Invariants /// # Invariants