Skip to content

Commit

Permalink
upgrade cita trie version
Browse files Browse the repository at this point in the history
  • Loading branch information
KaoImin committed Jul 28, 2023
1 parent dff856c commit 579a8a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions core/executor/src/adapter/trie_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl RocksTrieDB {
Arc::clone(&self.db)
}

fn inner_get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, RocksTrieDBError> {
fn inner_get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, String> {
use trie::DB;

let res = { self.cache.read().get(key).cloned() };
Expand Down Expand Up @@ -79,13 +79,11 @@ impl RocksTrieDB {
}

impl trie::DB for RocksTrieDB {
type Error = RocksTrieDBError;

fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error> {
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, String> {
self.inner_get(key)
}

fn contains(&self, key: &[u8]) -> Result<bool, Self::Error> {
fn contains(&self, key: &[u8]) -> Result<bool, String> {
let res = { self.cache.read().contains_key(key) };

if res {
Expand All @@ -99,7 +97,7 @@ impl trie::DB for RocksTrieDB {
}
}

fn insert(&self, key: Vec<u8>, value: Vec<u8>) -> Result<(), Self::Error> {
fn insert(&self, key: Vec<u8>, value: Vec<u8>) -> Result<(), String> {
let inst = Instant::now();
let size = key.len() + value.len();

Expand All @@ -114,9 +112,9 @@ impl trie::DB for RocksTrieDB {
self.flush()
}

fn insert_batch(&self, keys: Vec<Vec<u8>>, values: Vec<Vec<u8>>) -> Result<(), Self::Error> {
fn insert_batch(&self, keys: Vec<Vec<u8>>, values: Vec<Vec<u8>>) -> Result<(), String> {
if keys.len() != values.len() {
return Err(RocksTrieDBError::BatchLengthMismatch);
return Err(RocksTrieDBError::BatchLengthMismatch.to_string());
}

let mut total_size = 0;
Expand All @@ -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<u8>]) -> Result<(), Self::Error> {
fn remove_batch(&self, _keys: &[Vec<u8>]) -> Result<(), String> {
Ok(())
}

fn flush(&self) -> Result<(), Self::Error> {
fn flush(&self) -> Result<(), String> {
let mut cache = self.cache.write();

let len = cache.len();
Expand Down Expand Up @@ -232,9 +230,9 @@ impl From<RocksTrieDBError> 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)]
Expand Down
3 changes: 2 additions & 1 deletion protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 579a8a4

Please sign in to comment.