Skip to content

Commit

Permalink
fix: return -1 so blocknumber 0 is included
Browse files Browse the repository at this point in the history
  • Loading branch information
renancloudwalk committed Apr 3, 2024
1 parent 2a1fafd commit 16793b4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/eth/storage/hybrid/rocks_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ impl<K: Serialize + for<'de> Deserialize<'de> + std::hash::Hash + Eq, V: Seriali
bincode::deserialize(&value_bytes).ok()
}

pub fn get_current_block_number(&self) -> Option<i64> {
pub fn get_current_block_number(&self) -> i64 {
let Ok(serialized_key) = bincode::serialize(&"current_block") else {
return None;
return -1;
};
let Ok(Some(value_bytes)) = self.db.get(serialized_key) else { return None };
let Ok(Some(value_bytes)) = self.db.get(serialized_key) else { return -1 };

bincode::deserialize(&value_bytes).ok()
match bincode::deserialize(&value_bytes).ok() {
Some(block_number) => block_number,
None => -1,
}
}

// Mimics the 'insert' functionality of a HashMap
Expand Down

0 comments on commit 16793b4

Please sign in to comment.