diff --git a/Cargo.lock b/Cargo.lock index 5a5e3ac3f..2cc2464fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -867,8 +867,7 @@ dependencies = [ [[package]] name = "cita_trie" version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe7baab47f510f52ca8dc9c0eb9082020c627c7f22285bea30edc3511f7ee29" +source = "git+https://github.com/KaoImin/cita-trie.git?branch=test#b08d630f204197c4f97ce267cb9bbcf47509edcb" dependencies = [ "hasher", "parking_lot 0.12.1", diff --git a/core/executor/src/adapter/trie_db.rs b/core/executor/src/adapter/trie_db.rs index 20d75b0fb..c5e24b9ad 100644 --- a/core/executor/src/adapter/trie_db.rs +++ b/core/executor/src/adapter/trie_db.rs @@ -44,7 +44,7 @@ impl RocksTrieDB { Arc::clone(&self.db) } - fn inner_get(&self, key: &[u8]) -> Result>, RocksTrieDBError> { + fn inner_get(&self, key: &[u8]) -> Result>, String> { use trie::DB; let res = { self.cache.read().get(key).cloned() }; @@ -79,13 +79,11 @@ impl RocksTrieDB { } impl trie::DB for RocksTrieDB { - type Error = RocksTrieDBError; - - fn get(&self, key: &[u8]) -> Result>, Self::Error> { + fn get(&self, key: &[u8]) -> Result>, String> { self.inner_get(key) } - fn contains(&self, key: &[u8]) -> Result { + fn contains(&self, key: &[u8]) -> Result { let res = { self.cache.read().contains_key(key) }; if res { @@ -99,7 +97,7 @@ impl trie::DB for RocksTrieDB { } } - fn insert(&self, key: Vec, value: Vec) -> Result<(), Self::Error> { + fn insert(&self, key: Vec, value: Vec) -> Result<(), String> { let inst = Instant::now(); let size = key.len() + value.len(); @@ -114,9 +112,9 @@ impl trie::DB for RocksTrieDB { self.flush() } - fn insert_batch(&self, keys: Vec>, values: Vec>) -> Result<(), Self::Error> { + fn insert_batch(&self, keys: Vec>, values: Vec>) -> Result<(), String> { if keys.len() != values.len() { - return Err(RocksTrieDBError::BatchLengthMismatch); + return Err(RocksTrieDBError::BatchLengthMismatch.to_string()); } let mut total_size = 0; @@ -139,15 +137,15 @@ impl trie::DB for RocksTrieDB { self.flush() } - fn remove(&self, _key: &[u8]) -> Result<(), Self::Error> { + fn remove(&self, _key: &[u8]) -> Result<(), String> { Ok(()) } - fn remove_batch(&self, _keys: &[Vec]) -> Result<(), Self::Error> { + fn remove_batch(&self, _keys: &[Vec]) -> Result<(), String> { Ok(()) } - fn flush(&self) -> Result<(), Self::Error> { + fn flush(&self) -> Result<(), String> { let mut cache = self.cache.write(); let len = cache.len(); @@ -232,9 +230,9 @@ impl From for ProtocolError { } } -fn to_store_err(e: rocksdb::Error) -> RocksTrieDBError { +fn to_store_err(e: rocksdb::Error) -> String { log::error!("[executor] trie db {:?}", e); - RocksTrieDBError::Store + e.to_string() } #[cfg(test)] diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index b98a45ec9..5fd04a4f6 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -31,7 +31,8 @@ rlp = "0.5" rlp-derive = "0.1" serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.27", features = ["full"] } -trie = { package = "cita_trie", version = "4.0" } +# trie = { package = "cita_trie", version = "4.0" } +trie = { package = "cita_trie", git = "https://github.com/KaoImin/cita-trie.git", branch = "test" } common-crypto = { path = "../common/crypto" } common-hasher = { path = "../common/hasher" }