|
@ -639,8 +639,7 @@ void State::uncommitToMine() |
|
|
|
|
|
|
|
|
bool State::amIJustParanoid(BlockChain const& _bc) |
|
|
bool State::amIJustParanoid(BlockChain const& _bc) |
|
|
{ |
|
|
{ |
|
|
setUncles(_bc); |
|
|
commitToMine(_bc); |
|
|
commitToMine(); |
|
|
|
|
|
|
|
|
|
|
|
// Update difficulty according to timestamp.
|
|
|
// Update difficulty according to timestamp.
|
|
|
m_currentBlock.difficulty = m_currentBlock.calculateDifficulty(m_previousBlock); |
|
|
m_currentBlock.difficulty = m_currentBlock.calculateDifficulty(m_previousBlock); |
|
@ -683,8 +682,20 @@ LogBloom State::logBloom() const |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void State::setUncles(BlockChain const& _bc) |
|
|
void State::commitToMine(BlockChain const& _bc) |
|
|
{ |
|
|
{ |
|
|
|
|
|
uncommitToMine(); |
|
|
|
|
|
|
|
|
|
|
|
// cnote << "Committing to mine on block" << m_previousBlock.hash.abridged();
|
|
|
|
|
|
#ifdef ETH_PARANOIA |
|
|
|
|
|
commit(); |
|
|
|
|
|
cnote << "Pre-reward stateRoot:" << m_state.root(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
m_lastTx = m_db; |
|
|
|
|
|
|
|
|
|
|
|
Addresses uncleAddresses; |
|
|
|
|
|
|
|
|
RLPStream unclesData; |
|
|
RLPStream unclesData; |
|
|
unsigned unclesCount = 0; |
|
|
unsigned unclesCount = 0; |
|
|
if (m_previousBlock != BlockChain::genesis()) |
|
|
if (m_previousBlock != BlockChain::genesis()) |
|
@ -703,26 +714,11 @@ void State::setUncles(BlockChain const& _bc) |
|
|
BlockInfo ubi(_bc.block(u)); |
|
|
BlockInfo ubi(_bc.block(u)); |
|
|
ubi.streamRLP(unclesData, WithNonce); |
|
|
ubi.streamRLP(unclesData, WithNonce); |
|
|
++unclesCount; |
|
|
++unclesCount; |
|
|
|
|
|
uncleAddresses.push_back(ubi.coinbaseAddress); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
RLPStream(unclesCount).appendRaw(unclesData.out(), unclesCount).swapOut(m_currentUncles); |
|
|
|
|
|
m_currentBlock.sha3Uncles = sha3(m_currentUncles); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void State::commitToMine() |
|
|
|
|
|
{ |
|
|
|
|
|
uncommitToMine(); |
|
|
|
|
|
|
|
|
|
|
|
// cnote << "Committing to mine on block" << m_previousBlock.hash.abridged();
|
|
|
|
|
|
#ifdef ETH_PARANOIA |
|
|
|
|
|
commit(); |
|
|
|
|
|
cnote << "Pre-reward stateRoot:" << m_state.root(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
m_lastTx = m_db; |
|
|
|
|
|
|
|
|
|
|
|
MemoryDB tm; |
|
|
MemoryDB tm; |
|
|
GenericTrieDB<MemoryDB> transactionsTrie(&tm); |
|
|
GenericTrieDB<MemoryDB> transactionsTrie(&tm); |
|
|
transactionsTrie.init(); |
|
|
transactionsTrie.init(); |
|
@ -752,13 +748,12 @@ void State::commitToMine() |
|
|
|
|
|
|
|
|
txs.swapOut(m_currentTxs); |
|
|
txs.swapOut(m_currentTxs); |
|
|
|
|
|
|
|
|
|
|
|
RLPStream(unclesCount).appendRaw(unclesData.out(), unclesCount).swapOut(m_currentUncles); |
|
|
|
|
|
|
|
|
m_currentBlock.transactionsRoot = transactionsTrie.root(); |
|
|
m_currentBlock.transactionsRoot = transactionsTrie.root(); |
|
|
m_currentBlock.receiptsRoot = receiptsTrie.root(); |
|
|
m_currentBlock.receiptsRoot = receiptsTrie.root(); |
|
|
m_currentBlock.logBloom = logBloom(); |
|
|
m_currentBlock.logBloom = logBloom(); |
|
|
|
|
|
m_currentBlock.sha3Uncles = sha3(m_currentUncles); |
|
|
Addresses uncleAddresses; |
|
|
|
|
|
for (const auto& r: RLP(m_currentUncles)) |
|
|
|
|
|
uncleAddresses.push_back(BlockInfo::fromHeader(r.data()).coinbaseAddress); |
|
|
|
|
|
|
|
|
|
|
|
// Apply rewards last of all.
|
|
|
// Apply rewards last of all.
|
|
|
applyRewards(uncleAddresses); |
|
|
applyRewards(uncleAddresses); |
|
|