forked from nervosnetwork/fiber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
68 lines (56 loc) · 1.47 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
mod config;
pub use config::Config;
pub mod ckb;
pub mod fiber;
pub use fiber::{start_network, FiberConfig, NetworkServiceEvent};
pub mod cch;
pub use cch::{start_cch, CchActor, CchConfig};
pub mod rpc;
pub use rpc::{start_rpc, RpcConfig};
pub mod invoice;
pub mod store;
pub mod watchtower;
mod errors;
pub use errors::{Error, Result};
pub mod actors;
pub mod tasks;
#[cfg(test)]
mod tests;
use git_version::git_version;
const GIT_VERSION: &str = git_version!();
pub fn get_git_versin() -> &'static str {
GIT_VERSION
}
pub fn get_node_prefix() -> &'static str {
static INSTANCE: once_cell::sync::OnceCell<String> = once_cell::sync::OnceCell::new();
INSTANCE.get_or_init(|| std::env::var("LOG_PREFIX").unwrap_or_else(|_| "".to_string()))
}
pub fn now_timestamp() -> u64 {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.expect("Duration since unix epoch")
.as_millis() as u64
}
pub mod macros {
#[macro_export]
macro_rules! unwrap_or_return {
($expr:expr, $msg:expr) => {
match $expr {
Ok(val) => val,
Err(err) => {
error!("{}: {:?}", $msg, err);
return;
}
}
};
($expr:expr) => {
match $expr {
Ok(val) => val,
Err(err) => {
error!("{:?}", err);
return;
}
}
};
}
}