From 7eda4a4ceab02378079666f7336ccb119d7c52d6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 16 Feb 2014 23:59:03 +0000 Subject: [PATCH] Minor state reporting fix. --- libethereum/State.cpp | 11 ++++++++--- libethereum/State.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 42242d6d7..5b6436f4b 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -189,7 +189,7 @@ void State::commit() bool State::sync(BlockChain const& _bc) { - return sync(_bc, _bc.currentHash()); +return sync(_bc, _bc.currentHash()); } bool State::sync(BlockChain const& _bc, h256 _block) @@ -414,8 +414,6 @@ u256 State::playback(bytesConstRef _block, BlockInfo const& _grandParent, bool _ // (i.e. all the transactions we executed). void State::commitToMine(BlockChain const& _bc) { - cnote << "Commiting to mine on" << m_previousBlock.hash; - if (m_currentBlock.sha3Transactions != h256() || m_currentBlock.sha3Uncles != h256()) return; @@ -454,12 +452,19 @@ void State::commitToMine(BlockChain const& _bc) // Commit any and all changes to the trie that are in the cache, then update the state root accordingly. commit(); + m_currentBlock.stateRoot = m_state.root(); m_currentBlock.parentHash = m_previousBlock.hash; } MineInfo State::mine(uint _msTimeout) { + if (m_previousBlock.hash != m_committedPreviousHash) + { + m_committedPreviousHash = m_committedPreviousHash; + cnote << "Commiting to mine on" << m_previousBlock.hash; + } + // Update timestamp according to clock. m_currentBlock.timestamp = time(0); diff --git a/libethereum/State.h b/libethereum/State.h index a75acf131..7165b0847 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -224,6 +224,7 @@ private: BlockInfo m_currentBlock; ///< The current block's information. bytes m_currentBytes; ///< The current block. uint m_currentNumber; + h256 m_committedPreviousHash; ///< Hash of previous block that we are committing to mine. bytes m_currentTxs; bytes m_currentUncles;