1extern crate graphannis_malloc_size_of as malloc_size_of;
2extern crate graphannis_malloc_size_of_derive as malloc_size_of_derive;
3
4pub mod distributed_pool;
5pub mod invariants;
6pub mod log;
7pub mod requests;
8
9#[cfg(target_family = "wasm")]
11pub mod http;
12
13pub mod channels;
14pub mod thread;
15
16pub mod constants;
17pub mod dummy;
18
19pub mod block;
20pub mod p2p;
21pub mod snark;
22pub mod transaction;
23
24pub mod consensus;
25
26mod substate;
27
28pub use substate::{Substate, SubstateAccess, SubstateResult};
29
30pub mod network;
31pub use network::NetworkConfig;
32
33mod chain_id;
34pub use chain_id::*;
35
36pub mod encrypted_key;
37pub use encrypted_key::*;
38
39mod work_dir {
40 use once_cell::sync::OnceCell;
41 use std::path::PathBuf;
42
43 static HOME_DIR: OnceCell<PathBuf> = OnceCell::new();
44
45 pub fn set_work_dir(dir: PathBuf) {
46 HOME_DIR.set(dir).expect("Work dir can only be set once");
47 }
48
49 pub fn get_work_dir() -> PathBuf {
50 HOME_DIR.get().expect("Work dir is not set").clone()
51 }
52
53 pub fn get_debug_dir() -> PathBuf {
54 get_work_dir().join("debug")
55 }
56}
57
58pub use work_dir::{get_debug_dir, get_work_dir, set_work_dir};
59
60use rand::prelude::*;
61#[inline(always)]
62pub fn pseudo_rng(time: redux::Timestamp) -> StdRng {
63 StdRng::seed_from_u64(time.into())
64}
65
66pub fn preshared_key(chain_id: &ChainId) -> [u8; 32] {
67 use multihash::Hasher;
68 let mut hasher = Blake2b256::default();
69 hasher.update(b"/coda/0.0.1/");
70 hasher.update(chain_id.to_hex().as_bytes());
71 let hash = hasher.finalize();
72 let mut psk_fixed: [u8; 32] = Default::default();
73 psk_fixed.copy_from_slice(hash.as_ref());
74 psk_fixed
75}
76
77pub use log::ActionEvent;
78use multihash::Blake2b256;
79pub use openmina_macros::*;
80
81#[cfg(feature = "fuzzing")]
82pub use openmina_fuzzer::*;
83
84#[macro_export]
85macro_rules! fuzz_maybe {
86 ($expr:expr, $mutator:expr) => {
87 if cfg!(feature = "fuzzing") {
88 $crate::fuzz!($expr, $mutator);
89 }
90 };
91}
92
93#[macro_export]
94macro_rules! fuzzed_maybe {
95 ($expr:expr, $mutator:expr) => {
96 if cfg!(feature = "fuzzing") {
97 $crate::fuzzed!($expr, $mutator)
98 } else {
99 $expr
100 }
101 };
102}