diff --git a/libethereum/State.cpp b/libethereum/State.cpp index d1e430dbe..9bfc0c08c 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -555,7 +555,7 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) BOOST_THROW_EXCEPTION(TooManyUncles()); set nonces = { m_currentBlock.nonce }; - Addresses rewarded; + vector rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); for (auto const& i: rlp[2]) @@ -574,7 +574,7 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) nonces.insert(uncle.nonce); tdIncrease += uncle.difficulty; - rewarded.push_back(uncle.coinbaseAddress); + rewarded.push_back(uncle); } applyRewards(rewarded); @@ -696,7 +696,7 @@ void State::commitToMine(BlockChain const& _bc) m_lastTx = m_db; - Addresses uncleAddresses; + vector uncleBlockHeaders; RLPStream unclesData; unsigned unclesCount = 0; @@ -716,7 +716,7 @@ void State::commitToMine(BlockChain const& _bc) BlockInfo ubi(_bc.block(u)); ubi.streamRLP(unclesData, WithNonce); ++unclesCount; - uncleAddresses.push_back(ubi.coinbaseAddress); + uncleBlockHeaders.push_back(ubi); if (unclesCount == 2) break; } @@ -760,7 +760,7 @@ void State::commitToMine(BlockChain const& _bc) m_currentBlock.sha3Uncles = sha3(m_currentUncles); // Apply rewards last of all. - applyRewards(uncleAddresses); + applyRewards(uncleBlockHeaders); // Commit any and all changes to the trie that are in the cache, then update the state root accordingly. commit(); @@ -1148,12 +1148,12 @@ State State::fromPending(unsigned _i) const return ret; } -void State::applyRewards(Addresses const& _uncleAddresses) +void State::applyRewards(vector const& _uncleBlockHeaders) { u256 r = m_blockReward; - for (auto const& i: _uncleAddresses) + for (auto const& i: _uncleBlockHeaders) { - addBalance(i, m_blockReward * 15 / 16); + addBalance(i.coinbaseAddress, m_blockReward * (8 + i.number - m_currentBlock.number) / 8); r += m_blockReward / 32; } addBalance(m_currentBlock.coinbaseAddress, r); diff --git a/libethereum/State.h b/libethereum/State.h index 78ec85f38..1f8516fce 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -314,7 +314,7 @@ private: u256 enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce = true); /// Finalise the block, applying the earned rewards. - void applyRewards(Addresses const& _uncleAddresses); + void applyRewards(std::vector const& _uncleBlockHeaders); /// @returns gas used by transactions thus far executed. u256 gasUsed() const { return m_receipts.size() ? m_receipts.back().gasUsed() : 0; }