Skip to content

Commit

Permalink
storage: fix block heights used in read, write and delete
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Oct 27, 2022
1 parent 241bf88 commit f7fe272
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions shared/src/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ where
key: &Key,
height: BlockHeight,
) -> Result<(Option<Vec<u8>>, u64)> {
if height >= self.get_block_height().0 {
if height >= self.last_height {
self.read(key)
} else {
match self.db.read_subspace_val_with_height(key, height)? {
Expand Down Expand Up @@ -455,7 +455,7 @@ where
let len = value.len();
let gas = key.len() + len;
let size_diff =
self.db.write_subspace_val(self.last_height, key, value)?;
self.db.write_subspace_val(self.block.height, key, value)?;
Ok((gas as _, size_diff))
}

Expand All @@ -468,7 +468,7 @@ where
if self.has_key(key)?.0 {
self.block.tree.delete(key)?;
deleted_bytes_len =
self.db.delete_subspace_val(self.last_height, key)?;
self.db.delete_subspace_val(self.block.height, key)?;
}
let gas = key.len() + deleted_bytes_len as usize;
Ok((gas as _, deleted_bytes_len))
Expand Down

0 comments on commit f7fe272

Please sign in to comment.