zebra/zebra-chain/src/lib.rs

67 lines
1.8 KiB
Rust
Raw Normal View History

2020-08-15 21:55:28 -07:00
//! Core Zcash data structures. 🦓
//!
2020-08-15 21:55:28 -07:00
//! This crate provides definitions of core datastructures for Zcash, such as
//! blocks, transactions, addresses, etc.
2020-07-17 16:45:29 -07:00
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
#![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)]
#![allow(clippy::try_err)]
2020-11-15 19:00:08 -08:00
#![allow(clippy::unknown_clippy_lints)]
#![allow(clippy::from_iter_instead_of_collect)]
#[macro_use]
extern crate serde;
pub mod amount;
pub mod block;
pub mod parameters;
pub mod primitives;
pub mod sapling;
pub mod serialization;
pub mod sprout;
pub mod transaction;
pub mod transparent;
pub mod work;
2020-10-02 15:51:51 -07:00
#[derive(Debug, Clone, Copy)]
#[cfg(any(test, feature = "proptest-impl"))]
#[non_exhaustive]
/// The configuration data for proptest when generating arbitrary chains
2020-10-02 15:51:51 -07:00
pub struct LedgerState {
/// The tip height of the block or start of the chain
2020-10-02 15:51:51 -07:00
pub tip_height: block::Height,
is_coinbase: bool,
/// The network to generate fake blocks for
2020-10-02 15:51:51 -07:00
pub network: parameters::Network,
}
#[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,
}
}
}