Skip to content

Commit

Permalink
use track caller for database::get (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
laizy authored Sep 9, 2020
1 parent d90e902 commit 60f488f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ontio-std/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use super::abi::{Decoder, Encoder, Sink, Source};
use super::prelude::*;
use super::runtime;

#[track_caller]
pub fn get<K: AsRef<[u8]>, T>(key: K) -> Option<T>
where
for<'a> T: Decoder<'a> + 'static,
{
runtime::storage_read(key.as_ref()).map(|val: Vec<u8>| {
let mut source = Source::new(&val);
source.read().unwrap()
})
let val = runtime::storage_read(key.as_ref())?;
let mut source = Source::new(&val);
Some(source.read().unwrap())
}

pub fn put<K: AsRef<[u8]>, T: Encoder>(key: K, val: T) {
Expand Down

0 comments on commit 60f488f

Please sign in to comment.