Skip to content

Commit 10740c6

Browse files
committed
split cfxcore types into standard alone crate
1 parent 055fbb5 commit 10740c6

File tree

12 files changed

+75
-33
lines changed

12 files changed

+75
-33
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ members = [
109109
"crates/tasks",
110110
"crates/eest_types",
111111
"crates/config",
112+
"crates/cfxcore/types",
112113
]
113114

114115
resolver = "2"
@@ -181,6 +182,7 @@ secret-store = { path = "./crates/secret_store" }
181182
cfxstore = { path = "./crates/cfx_store" }
182183
network = { path = "./crates/network" }
183184
cfxcore = { path = "./crates/cfxcore/core" }
185+
cfxcore-types = { path = "./crates/cfxcore/types" }
184186
cfx-parameters = { path = "./crates/parameters" }
185187
cfx-execute-helper = { path = "./crates/execution/execute-helper" }
186188
cfx-executor = { path = "./crates/execution/executor" }
@@ -453,4 +455,4 @@ influx_db_client = "0.5.1"
453455
rocksdb = { git = "https://github.com/Conflux-Chain/rust-rocksdb.git", rev = "7dbd66f507db1d0cfdf5334ad56ca0b24a768740" }
454456

455457
[patch.crates-io]
456-
sqlite3-sys = { git = "https://github.com/Conflux-Chain/sqlite3-sys.git", rev = "1de8e5998f7c2d919336660b8ef4e8f52ac43844" }
458+
sqlite3-sys = { git = "https://github.com/Conflux-Chain/sqlite3-sys.git", rev = "1de8e5998f7c2d919336660b8ef4e8f52ac43844" }

crates/cfxcore/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ cfx-rpc-eth-types = { workspace = true }
117117
jsonrpsee = { workspace = true, features = ["jsonrpsee-types"] }
118118
cfx-rpc-utils = { workspace = true }
119119
cfx-util-macros = { workspace = true }
120+
cfxcore-types = { workspace = true }
120121

121122
[dev-dependencies]
122123
cfx-storage = { workspace = true, features = ["testonly_code"] }

crates/cfxcore/core/src/block_data_manager/block_data_types.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use cfx_internal_common::{
33
impl_db_encoding_as_rlp, DatabaseDecodable, DatabaseEncodable,
44
};
55
use cfx_types::{Address, Bloom, H256, U256};
6+
pub use cfxcore_types::block_data_manager::BlockStatus;
67
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
78
use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf;
89
use primitives::BlockReceipts;
@@ -276,31 +277,6 @@ impl Decodable for LocalBlockInfo {
276277
}
277278
}
278279

279-
/// The validity status of a block. If a block's status among all honest nodes
280-
/// is guaranteed to have no conflict, which means if some honest nodes think a
281-
/// block is not `Pending`, their decision will be the same status.
282-
#[derive(Copy, Clone, PartialEq, DeriveMallocSizeOf)]
283-
pub enum BlockStatus {
284-
Valid = 0,
285-
Invalid = 1,
286-
PartialInvalid = 2,
287-
Pending = 3,
288-
}
289-
290-
impl BlockStatus {
291-
fn from_db_status(db_status: u8) -> Self {
292-
match db_status {
293-
0 => BlockStatus::Valid,
294-
1 => BlockStatus::Invalid,
295-
2 => BlockStatus::PartialInvalid,
296-
3 => BlockStatus::Pending,
297-
_ => panic!("Read unknown block status from db"),
298-
}
299-
}
300-
301-
pub fn to_db_status(&self) -> u8 { *self as u8 }
302-
}
303-
304280
/// The checkpoint information stored in the database
305281
#[derive(RlpEncodable, RlpDecodable, Clone)]
306282
pub struct CheckpointHashes {

crates/cfxcore/core/src/state_exposer/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
// Conflux is free software and distributed under GNU General Public License.
33
// See http://www.gnu.org/licenses/
44

5-
mod consensus_graph_exposer;
65
mod network_exposer;
76
mod sync_graph_exposer;
87

98
pub use self::{
10-
consensus_graph_exposer::{
11-
ConsensusGraphBlockExecutionState, ConsensusGraphBlockState,
12-
ConsensusGraphStates,
13-
},
149
network_exposer::NetworkExposer,
1510
sync_graph_exposer::{SyncGraphBlockState, SyncGraphStates},
1611
};
12+
pub use cfxcore_types::state_exposer::consensus_graph_exposer::{
13+
ConsensusGraphBlockExecutionState, ConsensusGraphBlockState,
14+
ConsensusGraphStates,
15+
};
1716

1817
use parking_lot::Mutex;
1918
use std::sync::Arc;

crates/cfxcore/types/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "cfxcore-types"
3+
version.workspace = true
4+
authors.workspace = true
5+
description.workspace = true
6+
documentation.workspace = true
7+
homepage.workspace = true
8+
keywords.workspace = true
9+
repository.workspace = true
10+
license-file.workspace = true
11+
edition.workspace = true
12+
13+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
14+
15+
[dependencies]
16+
cfx-types = { workspace = true }
17+
malloc_size_of = { workspace = true }
18+
malloc_size_of_derive = { workspace = true }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf;
2+
3+
/// The validity status of a block. If a block's status among all honest nodes
4+
/// is guaranteed to have no conflict, which means if some honest nodes think a
5+
/// block is not `Pending`, their decision will be the same status.
6+
#[derive(Copy, Clone, PartialEq, DeriveMallocSizeOf)]
7+
pub enum BlockStatus {
8+
Valid = 0,
9+
Invalid = 1,
10+
PartialInvalid = 2,
11+
Pending = 3,
12+
}
13+
14+
impl BlockStatus {
15+
pub fn from_db_status(db_status: u8) -> Self {
16+
match db_status {
17+
0 => BlockStatus::Valid,
18+
1 => BlockStatus::Invalid,
19+
2 => BlockStatus::PartialInvalid,
20+
3 => BlockStatus::Pending,
21+
_ => panic!("Read unknown block status from db"),
22+
}
23+
}
24+
25+
pub fn to_db_status(&self) -> u8 { *self as u8 }
26+
}

crates/cfxcore/types/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod block_data_manager;
2+
pub mod state_exposer;

crates/cfxcore/core/src/state_exposer/consensus_graph_exposer.rs renamed to crates/cfxcore/types/src/state_exposer/consensus_graph_exposer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Conflux is free software and distributed under GNU General Public License.
33
// See http://www.gnu.org/licenses/
44

5-
use crate::block_data_manager::block_data_types::BlockStatus;
5+
use crate::block_data_manager::BlockStatus;
66
use cfx_types::H256;
77
use std::mem;
88

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pub mod consensus_graph_exposer;
2+
3+
pub use consensus_graph_exposer::{
4+
ConsensusGraphBlockExecutionState, ConsensusGraphBlockState,
5+
ConsensusGraphStates,
6+
};

0 commit comments

Comments
 (0)