Skip to content

Commit

Permalink
perhaps this is better for now
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Jan 14, 2024
1 parent 6a46ddb commit fd7e817
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion core/src/ledger/masp_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ fn reveal_nullifiers(
.sapling_bundle()
.map_or(&vec![], |description| &description.shielded_spends)
{
ctx.write_without_merkldiffs(&masp_nullifier_key(&description.nullifier), ())?;
ctx.write_without_merkldiffs(
&masp_nullifier_key(&description.nullifier),
(),
)?;
}

Ok(())
Expand Down
18 changes: 12 additions & 6 deletions core/src/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use crate::types::storage::{
BLOCK_HEIGHT_LENGTH, EPOCH_TYPE_LENGTH,
};
use crate::types::time::DateTimeUtc;
use crate::types::token::is_masp_key;

/// A result of a function that may fail
pub type Result<T> = std::result::Result<T, Error>;
Expand Down Expand Up @@ -600,19 +601,24 @@ where
/// gas cost.
pub fn has_key(&self, key: &Key) -> Result<(bool, u64)> {
Ok((
// self.block.tree.has_key(key)?,
self.db.read_subspace_val(key)?.is_some(),
if is_masp_key(key) {
self.db.read_subspace_val(key)?.is_some()
} else {
self.block.tree.has_key(key)?
},
key.len() as u64 * STORAGE_ACCESS_GAS_PER_BYTE,
))
}

/// Returns a value from the specified subspace and the gas cost
pub fn read(&self, key: &Key) -> Result<(Option<Vec<u8>>, u64)> {
tracing::debug!("storage read key {}", key);
// let (present, gas) = self.has_key(key)?;
// if !present {
// return Ok((None, gas));
// }
if !is_masp_key(key) {
let (present, gas) = self.has_key(key)?;
if !present {
return Ok((None, gas));
}
}

match self.db.read_subspace_val(key)? {
Some(v) => {
Expand Down

0 comments on commit fd7e817

Please sign in to comment.