2020-08-15 21:55:28 -07:00
|
|
|
//! Core Zcash data structures. 🦓
|
2020-08-05 17:34:30 -07:00
|
|
|
//!
|
2020-08-15 21:55:28 -07:00
|
|
|
//! This crate provides definitions of core datastructures for Zcash, such as
|
|
|
|
//! blocks, transactions, addresses, etc.
|
2020-02-26 21:10:08 -08:00
|
|
|
|
2020-07-17 16:45:29 -07:00
|
|
|
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
|
2020-02-26 21:10:08 -08:00
|
|
|
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
|
|
|
|
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_chain")]
|
2020-10-02 15:51:51 -07:00
|
|
|
// #![deny(missing_docs)]
|
2020-09-05 16:31:11 -07:00
|
|
|
#![allow(clippy::try_err)]
|
2019-09-10 13:27:10 -07:00
|
|
|
|
2020-03-10 16:44:19 -07:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde;
|
|
|
|
|
2020-08-15 18:02:07 -07:00
|
|
|
pub mod amount;
|
|
|
|
pub mod block;
|
2020-08-09 16:56:57 -07:00
|
|
|
pub mod parameters;
|
2020-08-15 16:33:46 -07:00
|
|
|
pub mod primitives;
|
2020-08-15 18:02:07 -07:00
|
|
|
pub mod sapling;
|
2019-09-19 07:45:37 -07:00
|
|
|
pub mod serialization;
|
2020-08-15 18:02:07 -07:00
|
|
|
pub mod sprout;
|
2019-09-19 07:45:37 -07:00
|
|
|
pub mod transaction;
|
2020-08-15 18:02:07 -07:00
|
|
|
pub mod transparent;
|
2020-08-15 00:14:07 -07:00
|
|
|
pub mod work;
|
2020-10-02 15:51:51 -07:00
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
#[cfg(any(test, feature = "proptest-impl"))]
|
2020-10-07 20:07:32 -07:00
|
|
|
#[non_exhaustive]
|
|
|
|
/// The configuration data for proptest when generating arbitrary chains
|
2020-10-02 15:51:51 -07:00
|
|
|
pub struct LedgerState {
|
2020-10-07 20:07:32 -07:00
|
|
|
/// The tip height of the block or start of the chain
|
2020-10-02 15:51:51 -07:00
|
|
|
pub tip_height: block::Height,
|
2020-10-07 20:07:32 -07:00
|
|
|
is_coinbase: bool,
|
|
|
|
/// The network to generate fake blocks for
|
2020-10-02 15:51:51 -07:00
|
|
|
pub network: parameters::Network,
|
|
|
|
}
|
|
|
|
|
2020-10-07 20:07:32 -07:00
|
|
|
#[cfg(any(test, feature = "proptest-impl"))]
|
|
|
|
impl LedgerState {
|
|
|
|
/// Construct a new ledger state for generating arbitrary chains via proptest
|
|
|
|
pub fn new(tip_height: block::Height, network: parameters::Network) -> Self {
|
|
|
|
Self {
|
|
|
|
tip_height,
|
|
|
|
is_coinbase: true,
|
|
|
|
network,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 15:51:51 -07:00
|
|
|
#[cfg(any(test, feature = "proptest-impl"))]
|
|
|
|
impl Default for LedgerState {
|
|
|
|
fn default() -> Self {
|
|
|
|
let network = parameters::Network::Mainnet;
|
|
|
|
let tip_height = parameters::NetworkUpgrade::Sapling
|
|
|
|
.activation_height(network)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
Self {
|
|
|
|
tip_height,
|
|
|
|
is_coinbase: true,
|
|
|
|
network,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|