Skip to content

Commit 391aa14

Browse files
author
Seulgi Kim
committed
Rename from_db to from_global_cache
From_db is a wrong name.
1 parent 136e508 commit 391aa14

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

state/src/impls/top_level.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ impl TopLevelState {
619619
debug_assert_eq!(Ok(false), self.regular_account_exists_and_not_null(a));
620620

621621
let db = TrieFactory::readonly(self.db.as_hashdb(), &self.root)?;
622-
let from_db = || self.db.get_cached_account(&a);
623-
self.account.require_item_or_from(&a, db, from_db)
622+
let from_global_cache = || self.db.get_cached_account(&a);
623+
self.account.require_item_or_from(&a, db, from_global_cache)
624624
}
625625

626626
/// Check caches for required data
@@ -638,35 +638,35 @@ impl TopLevelState {
638638
fn require_regular_account(&self, public: &Public) -> TrieResult<RefMut<RegularAccount>> {
639639
let regular_account_address = RegularAccountAddress::new(public);
640640
let db = TrieFactory::readonly(self.db.as_hashdb(), &self.root)?;
641-
let from_db = || self.db.get_cached_regular_account(&regular_account_address);
642-
self.regular_account.require_item_or_from(&regular_account_address, db, from_db)
641+
let from_global_cache = || self.db.get_cached_regular_account(&regular_account_address);
642+
self.regular_account.require_item_or_from(&regular_account_address, db, from_global_cache)
643643
}
644644

645645
fn require_regular_account_from_address(&self, a: &Address) -> TrieResult<RefMut<RegularAccount>> {
646646
let regular_account_address = RegularAccountAddress::from_address(a);
647647
let db = TrieFactory::readonly(self.db.as_hashdb(), &self.root)?;
648-
let from_db = || self.db.get_cached_regular_account(&regular_account_address);
649-
self.regular_account.require_item_or_from(&regular_account_address, db, from_db)
648+
let from_global_cache = || self.db.get_cached_regular_account(&regular_account_address);
649+
self.regular_account.require_item_or_from(&regular_account_address, db, from_global_cache)
650650
}
651651

652652
fn require_metadata(&self) -> TrieResult<RefMut<Metadata>> {
653653
let db = TrieFactory::readonly(self.db.as_hashdb(), &self.root)?;
654654
let address = MetadataAddress::new();
655-
let from_db = || self.db.get_cached_metadata(&address);
656-
self.metadata.require_item_or_from(&address, db, from_db)
655+
let from_global_cache = || self.db.get_cached_metadata(&address);
656+
self.metadata.require_item_or_from(&address, db, from_global_cache)
657657
}
658658

659659
fn require_shard(&self, shard_id: ShardId) -> TrieResult<RefMut<Shard>> {
660660
let db = TrieFactory::readonly(self.db.as_hashdb(), &self.root)?;
661661
let shard_address = ShardAddress::new(shard_id);
662-
let from_db = || self.db.get_cached_shard(&shard_address);
663-
self.shard.require_item_or_from(&shard_address, db, from_db)
662+
let from_global_cache = || self.db.get_cached_shard(&shard_address);
663+
self.shard.require_item_or_from(&shard_address, db, from_global_cache)
664664
}
665665

666666
fn require_action_data(&self, key: &H256) -> TrieResult<RefMut<ActionData>> {
667667
let db = TrieFactory::readonly(self.db.as_hashdb(), &self.root)?;
668-
let from_db = || self.db.get_cached_action_data(key);
669-
self.action_data.require_item_or_from(key, db, from_db)
668+
let from_global_cache = || self.db.get_cached_action_data(key);
669+
self.action_data.require_item_or_from(key, db, from_global_cache)
670670
}
671671
}
672672

state/src/item/cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ where
257257
&self,
258258
a: &Item::Address,
259259
db: TrieDB<'db>,
260-
from_db: G,
260+
from_global_cache: G,
261261
) -> cmerkle::Result<RefMut<Item>>
262262
where
263263
G: FnOnce() -> Option<Option<Item>>, {
264264
let contains_key = self.cache.borrow().contains_key(a);
265265
if !contains_key {
266-
match from_db() {
266+
match from_global_cache() {
267267
Some(item) => self.insert(a, Entry::<Item>::new_clean_cached(item)),
268268
None => {
269269
let maybe_item = Entry::<Item>::new_clean(db.get_with(a.as_ref(), ::rlp::decode::<Item>)?);

0 commit comments

Comments
 (0)