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

Commit

Permalink
The code can be always rolled back to empty, no need to save the old …
Browse files Browse the repository at this point in the history
…code.

Because it's not allowed to overwrite code now.
  • Loading branch information
gumb0 committed Jun 26, 2019
1 parent 60e72b5 commit 4a9ff0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libethereum/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ bytes const& State::code(Address const& _addr) const

void State::setCode(Address const& _address, bytes&& _code)
{
m_changeLog.emplace_back(_address, code(_address));
m_changeLog.emplace_back(Change::Code, _address);
m_cache[_address].setCode(std::move(_code));
}

Expand Down Expand Up @@ -583,7 +583,7 @@ void State::rollback(size_t _savepoint)
m_cache.erase(change.address);
break;
case Change::Code:
account.setCode(std::move(change.oldCode));
account.setCode(bytes{});
break;
case Change::Touch:
account.untouch();
Expand Down
6 changes: 0 additions & 6 deletions libethereum/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ struct Change
Address address; ///< Changed account address.
u256 value; ///< Change value, e.g. balance, storage and nonce.
u256 key; ///< Storage key. Last because used only in one case.
bytes oldCode; ///< Code overwritten by CREATE, empty except in case of address collision.

/// Helper constructor to make change log update more readable.
Change(Kind _kind, Address const& _addr, u256 const& _value = 0):
Expand All @@ -134,11 +133,6 @@ struct Change
Change(Address const& _addr, u256 const& _value):
kind(Nonce), address(_addr), value(_value)
{}

/// Helper constructor especially for new code change log.
Change(Address const& _addr, bytes const& _oldCode):
kind(Code), address(_addr), oldCode(_oldCode)
{}
};

using ChangeLog = std::vector<Change>;
Expand Down

0 comments on commit 4a9ff0f

Please sign in to comment.