Browse Source

Merge remote-tracking branch 'upstream/develop' into stateTests

cl-refactor
Christoph Jentzsch 10 years ago
parent
commit
2e23abbbeb
  1. 2
      libethereum/Account.h
  2. 10
      libethereum/State.cpp
  3. 4
      libethereum/State.h

2
libethereum/Account.h

@ -123,7 +123,7 @@ public:
h256 baseRoot() const { assert(m_storageRoot); return m_storageRoot; }
/// @returns the storage overlay as a simple map.
std::map<u256, u256> const& storage() const { return m_storageOverlay; }
std::map<u256, u256> const& storageOverlay() const { return m_storageOverlay; }
/// Set a key/value pair in the account's storage. This actually goes into the overlay, for committing
/// to the trie later.

10
libethereum/State.cpp

@ -259,7 +259,7 @@ struct CachedAddressState
ret[j.first] = RLP(j.second).toInt<u256>();
}
if (s)
for (auto const& j: s->storage())
for (auto const& j: s->storageOverlay())
if ((!ret.count(j.first) && j.second) || (ret.count(j.first) && ret.at(j.first) != j.second))
ret[j.first] = j.second;
return ret;
@ -1011,8 +1011,8 @@ u256 State::storage(Address _id, u256 _memory) const
return 0;
// See if it's in the account's storage cache.
auto mit = it->second.storage().find(_memory);
if (mit != it->second.storage().end())
auto mit = it->second.storageOverlay().find(_memory);
if (mit != it->second.storageOverlay().end())
return mit->second;
// Not in the storage cache - go to the DB.
@ -1040,7 +1040,7 @@ map<u256, u256> State::storage(Address _id) const
}
// Then merge cached storage over the top.
for (auto const& i: it->second.storage())
for (auto const& i: it->second.storageOverlay())
if (i.second)
ret[i.first] = i.second;
else
@ -1394,7 +1394,7 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s)
mem[j.first] = RLP(j.second).toInt<u256>(), back.insert(j.first);
}
if (cache)
for (auto const& j: cache->storage())
for (auto const& j: cache->storageOverlay())
{
if ((!mem.count(j.first) && j.second) || (mem.count(j.first) && mem.at(j.first) != j.second))
mem[j.first] = j.second, delta.insert(j.first);

4
libethereum/State.h

@ -376,7 +376,7 @@ void commit(std::map<Address, Account> const& _cache, DB& _db, TrieDB<Address, D
RLPStream s(4);
s << i.second.nonce() << i.second.balance();
if (i.second.storage().empty())
if (i.second.storageOverlay().empty())
{
assert(i.second.baseRoot());
s.append(i.second.baseRoot());
@ -384,7 +384,7 @@ void commit(std::map<Address, Account> const& _cache, DB& _db, TrieDB<Address, D
else
{
TrieDB<h256, DB> storageDB(&_db, i.second.baseRoot());
for (auto const& j: i.second.storage())
for (auto const& j: i.second.storageOverlay())
if (j.second)
storageDB.insert(j.first, rlp(j.second));
else

Loading…
Cancel
Save