Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Combine State::ensureCached into State::account.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Oct 28, 2016
1 parent 6162531 commit 777d14d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion deps
Submodule deps updated 3 files
+3 −0 install_deps.cmake
+0 −26 jsoncpp.cmake
+0 −89 jsonrpc.cmake
17 changes: 6 additions & 11 deletions libethereum/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ StateDiff State::diff(State const& _c, bool _quick) const
}

Account const* State::account(Address const& _a, bool _requireCode) const
{
return ensureCached(_a, _requireCode);
}

Account* State::account(Address const& _a, bool _requireCode)
{
return ensureCached(_a, _requireCode);
}

Account* State::ensureCached(Address const& _a, bool _requireCode) const
{
Account *a = nullptr;
auto it = m_cache.find(_a);
Expand All @@ -233,7 +223,6 @@ Account* State::ensureCached(Address const& _a, bool _requireCode) const

clearCacheIfTooLarge();


RLP state(stateBack);
m_cache[_a] = Account(state[0].toInt<u256>(), state[1].toInt<u256>(), state[2].toHash<h256>(), state[3].toHash<h256>(), Account::Unchanged);
m_unchangedCacheEntries.insert(_a);
Expand All @@ -247,6 +236,12 @@ Account* State::ensureCached(Address const& _a, bool _requireCode) const
return a;
}

Account* State::account(Address const& _a, bool _requireCode)
{
return const_cast<Account*>(account(_a, _requireCode));
}


void State::clearCacheIfTooLarge() const
{
// TODO: Find a good magic number
Expand Down
5 changes: 0 additions & 5 deletions libethereum/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,6 @@ class State
/// The pointer is valid until the next access to the state or account.
Account* account(Address const& _a, bool _requireCode = false);

/// Retrieve certain information about a given address into the cache and return
/// a pointer to the relevant account (or a null pointer if it does not exist).
/// If _requireCode is true, also load the code.
Account* ensureCached(Address const& _a, bool _requireCode) const;

/// Purges non-modified entries in m_cache if it grows too large.
void clearCacheIfTooLarge() const;

Expand Down

0 comments on commit 777d14d

Please sign in to comment.