Browse Source

Merge pull request #1910 from arkpar/core_state

Check nonce only once on block import
cl-refactor
Gav Wood 10 years ago
parent
commit
fdd3e4f049
  1. 2
      libethereum/BlockChain.cpp
  2. 8
      libethereum/State.cpp
  3. 2
      libethereum/State.h

2
libethereum/BlockChain.cpp

@ -639,7 +639,7 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import
} }
try { try {
State canary(_db, *this, bi.hash()); State canary(_db, *this, bi.hash(), ImportRequirements::DontHave);
} }
catch (...) catch (...)
{ {

8
libethereum/State.cpp

@ -114,7 +114,7 @@ State::State(OverlayDB const& _db, BaseState _bs, Address _coinbaseAddress):
paranoia("end of normal construction.", true); paranoia("end of normal construction.", true);
} }
State::State(OverlayDB const& _db, BlockChain const& _bc, h256 _h): State::State(OverlayDB const& _db, BlockChain const& _bc, h256 _h, ImportRequirements::value _ir):
m_db(_db), m_db(_db),
m_state(&m_db), m_state(&m_db),
m_blockReward(c_blockReward) m_blockReward(c_blockReward)
@ -136,18 +136,18 @@ State::State(OverlayDB const& _db, BlockChain const& _bc, h256 _h):
// 1. Start at parent's end state (state root). // 1. Start at parent's end state (state root).
BlockInfo bip; BlockInfo bip;
bip.populate(_bc.block(bi.parentHash)); bip.populate(_bc.block(bi.parentHash));
sync(_bc, bi.parentHash, bip); sync(_bc, bi.parentHash, bip, _ir);
// 2. Enact the block's transactions onto this state. // 2. Enact the block's transactions onto this state.
m_ourAddress = bi.coinbaseAddress; m_ourAddress = bi.coinbaseAddress;
enact(&b, _bc); enact(&b, _bc, _ir);
} }
else else
{ {
// Genesis required: // Genesis required:
// We know there are no transactions, so just populate directly. // We know there are no transactions, so just populate directly.
m_state.init(); m_state.init();
sync(_bc, _h, bi); sync(_bc, _h, bi, _ir);
} }
} }

2
libethereum/State.h

@ -118,7 +118,7 @@ public:
explicit State(OverlayDB const& _db, BaseState _bs = BaseState::PreExisting, Address _coinbaseAddress = Address()); explicit State(OverlayDB const& _db, BaseState _bs = BaseState::PreExisting, Address _coinbaseAddress = Address());
/// Construct state object from arbitrary point in blockchain. /// Construct state object from arbitrary point in blockchain.
State(OverlayDB const& _db, BlockChain const& _bc, h256 _hash); State(OverlayDB const& _db, BlockChain const& _bc, h256 _hash, ImportRequirements::value _ir = ImportRequirements::Default);
/// Copy state object. /// Copy state object.
State(State const& _s); State(State const& _s);

Loading…
Cancel
Save