snarkvm_ledger_store/
lib.rs1#![forbid(unsafe_code)]
17#![warn(clippy::cast_possible_truncation)]
18
19pub mod helpers;
20
21mod block;
22pub use block::*;
23
24mod consensus;
25pub use consensus::*;
26
27mod program;
28pub use program::*;
29
30mod transaction;
31pub use transaction::*;
32
33mod transition;
34pub use transition::*;
35
36#[macro_export]
37macro_rules! cow_to_copied {
38 ($cow:expr) => {
39 match $cow {
40 std::borrow::Cow::Borrowed(inner) => *inner,
41 std::borrow::Cow::Owned(inner) => inner,
42 }
43 };
44}
45
46#[macro_export]
47macro_rules! cow_to_cloned {
48 ($cow:expr) => {
49 match $cow {
50 std::borrow::Cow::Borrowed(inner) => (*inner).clone(),
51 std::borrow::Cow::Owned(inner) => inner,
52 }
53 };
54}
55
56use console::prelude::{Result, bail};
57
58#[derive(Copy, Clone, Debug, PartialEq, Eq)]
59pub enum FinalizeMode {
60 RealRun,
62 DryRun,
64}
65
66impl FinalizeMode {
67 #[inline]
69 pub const fn to_u8(self) -> u8 {
70 match self {
71 Self::RealRun => 0,
72 Self::DryRun => 1,
73 }
74 }
75
76 #[inline]
78 pub fn from_u8(value: u8) -> Result<Self> {
79 match value {
80 0 => Ok(Self::RealRun),
81 1 => Ok(Self::DryRun),
82 _ => bail!("Invalid finalize mode of '{value}'"),
83 }
84 }
85}