use NULL_RLP, remove NULL_RLP_STATIC (#5742)

This commit is contained in:
Guanqun Lu 2017-06-07 17:58:39 +08:00 committed by Arkadiy Paronyan
parent 19f01194b1
commit 05aa960c25
2 changed files with 6 additions and 10 deletions

View File

@ -18,8 +18,6 @@
use util::*;
use rlp::NULL_RLP;
static NULL_RLP_STATIC: [u8; 1] = [0x80; 1];
// combines a key with an address hash to ensure uniqueness.
// leaves the first 96 bits untouched in order to support partial key lookup.
#[inline]
@ -99,7 +97,7 @@ impl<'db> HashDB for AccountDB<'db>{
fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP_STATIC));
return Some(DBValue::from_slice(&NULL_RLP));
}
self.db.get(&combine_key(&self.address_hash, key))
}
@ -158,7 +156,7 @@ impl<'db> HashDB for AccountDBMut<'db>{
fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP_STATIC));
return Some(DBValue::from_slice(&NULL_RLP));
}
self.db.get(&combine_key(&self.address_hash, key))
}
@ -206,7 +204,7 @@ impl<'db> HashDB for Wrapping<'db> {
fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP_STATIC));
return Some(DBValue::from_slice(&NULL_RLP));
}
self.0.get(key)
}
@ -240,7 +238,7 @@ impl<'db> HashDB for WrappingMut<'db>{
fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP_STATIC));
return Some(DBValue::from_slice(&NULL_RLP));
}
self.0.get(key)
}

View File

@ -122,7 +122,7 @@ impl MemoryDB {
/// when the refs > 0.
pub fn raw(&self, key: &H256) -> Option<(DBValue, i32)> {
if key == &SHA3_NULL_RLP {
return Some((DBValue::from_slice(&NULL_RLP_STATIC), 1));
return Some((DBValue::from_slice(&NULL_RLP), 1));
}
self.data.get(key).cloned()
}
@ -172,12 +172,10 @@ impl MemoryDB {
}
}
static NULL_RLP_STATIC: [u8; 1] = [0x80; 1];
impl HashDB for MemoryDB {
fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP_STATIC));
return Some(DBValue::from_slice(&NULL_RLP));
}
match self.data.get(key) {