diff --git a/spec/src/versionbits/mod.rs b/spec/src/versionbits/mod.rs index ac3911e960b..443b37bcf41 100644 --- a/spec/src/versionbits/mod.rs +++ b/spec/src/versionbits/mod.rs @@ -4,15 +4,16 @@ mod convert; use crate::consensus::Consensus; +use ckb_logger::error; use ckb_types::{ - core::{EpochExt, EpochNumber, HeaderView, Ratio, TransactionView, Version, DATA_DIR}, + core::{EpochExt, EpochNumber, HeaderView, Ratio, TransactionView, Version}, + global::DATA_DIR, packed::{Byte32, CellbaseWitnessReader}, prelude::*, }; use std::fmt; use std::sync::Arc; use std::{collections::HashMap, path::PathBuf}; -use ckb_logger::error; /// What bits to set in version for versionbits blocks pub const VERSIONBITS_TOP_BITS: Version = 0x00000000; @@ -155,7 +156,11 @@ impl Cache { } pub fn insert(&self, key: &Byte32, value: ThresholdState) { - if let Err(e) = cacache::write_sync(&self.path, Self::encode_key(&key), Self::encode_value(value)) { + if let Err(e) = cacache::write_sync( + &self.path, + Self::encode_key(&key), + Self::encode_value(value), + ) { error!("cacache write_sync failed {:?}", e); } } diff --git a/util/app-config/src/app_config.rs b/util/app-config/src/app_config.rs index edf597a33cf..476ed1a4e44 100644 --- a/util/app-config/src/app_config.rs +++ b/util/app-config/src/app_config.rs @@ -4,7 +4,7 @@ //! we must put nested config struct in the tail to make it serializable, //! details -use ckb_types::core::DATA_DIR; +use ckb_types::global::DATA_DIR; use path_clean::PathClean; use std::fs; use std::path::{Path, PathBuf}; diff --git a/util/types/src/core/mod.rs b/util/types/src/core/mod.rs index 3abcc950c54..ae8602a5771 100644 --- a/util/types/src/core/mod.rs +++ b/util/types/src/core/mod.rs @@ -32,9 +32,7 @@ pub use advanced_builders::{BlockBuilder, HeaderBuilder, TransactionBuilder}; pub use blockchain::DepType; pub use extras::{BlockExt, EpochExt, EpochNumberWithFraction, TransactionInfo}; pub use fee_rate::FeeRate; -use once_cell::sync::OnceCell; pub use reward::{BlockEconomicState, BlockIssuance, BlockReward, MinerReward}; -use std::path::PathBuf; pub use transaction_meta::{TransactionMeta, TransactionMetaBuilder}; pub use tx_pool::TransactionWithStatus; pub use views::{ @@ -61,5 +59,3 @@ pub type Cycle = u64; /// Version number. pub type Version = u32; - -pub static DATA_DIR: OnceCell = OnceCell::new(); diff --git a/util/types/src/global.rs b/util/types/src/global.rs new file mode 100644 index 00000000000..c8f4709c593 --- /dev/null +++ b/util/types/src/global.rs @@ -0,0 +1,8 @@ +//! Global data, initialized in the launch phase. + + +use once_cell::sync::OnceCell; +use std::path::PathBuf; + +/// ckb data directory path, located under root/data, initialized during the launch phase +pub static DATA_DIR: OnceCell = OnceCell::new(); diff --git a/util/types/src/lib.rs b/util/types/src/lib.rs index 3e823f91e31..6b559dd614d 100644 --- a/util/types/src/lib.rs +++ b/util/types/src/lib.rs @@ -11,6 +11,7 @@ pub use molecule::{self, error}; pub use numext_fixed_uint::{u256, U128, U256}; pub mod core; +pub mod global; pub mod constants; mod conversion;