Browse Source

Merge pull request #2332 from arkpar/bc

Fixed block memory corruption on windows
cl-refactor
Gav Wood 10 years ago
parent
commit
5440ee64a9
  1. 2
      libethereum/BlockChain.cpp
  2. 6
      libethereum/BlockQueue.cpp
  3. 2
      libethereum/State.cpp
  4. 24
      libethereum/VerifiedBlock.h

2
libethereum/BlockChain.cpp

@ -541,7 +541,7 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const&
#endif #endif
} }
#if ETH_CATCH #if ETH_CATCH
catch (BadRoot& ex) catch (BadRoot&)
{ {
cwarn << "BadRoot error. Retrying import later."; cwarn << "BadRoot error. Retrying import later.";
BOOST_THROW_EXCEPTION(FutureTime()); BOOST_THROW_EXCEPTION(FutureTime());

6
libethereum/BlockQueue.cpp

@ -102,7 +102,7 @@ void BlockQueue::verifierBody()
BlockInfo bi; BlockInfo bi;
bi.mixHash = work.hash; bi.mixHash = work.hash;
bi.parentHash = work.parentHash; bi.parentHash = work.parentHash;
m_verifying.push_back(VerifiedBlock { VerifiedBlockRef { bytesConstRef(), move(bi), Transactions() }, bytes() }); m_verifying.emplace_back(move(bi));
} }
VerifiedBlock res; VerifiedBlock res;
@ -148,7 +148,7 @@ void BlockQueue::verifierBody()
m_knownBad.insert(res.verified.info.hash()); m_knownBad.insert(res.verified.info.hash());
} }
else else
m_verified.push_back(move(res)); m_verified.emplace_back(move(res));
while (m_verifying.size() && !m_verifying.front().blockData.empty()) while (m_verifying.size() && !m_verifying.front().blockData.empty())
{ {
if (m_knownBad.count(m_verifying.front().verified.info.parentHash)) if (m_knownBad.count(m_verifying.front().verified.info.parentHash))
@ -157,7 +157,7 @@ void BlockQueue::verifierBody()
m_knownBad.insert(res.verified.info.hash()); m_knownBad.insert(res.verified.info.hash());
} }
else else
m_verified.push_back(move(m_verifying.front())); m_verified.emplace_back(move(m_verifying.front()));
m_verifying.pop_front(); m_verifying.pop_front();
} }
ready = true; ready = true;

2
libethereum/State.cpp

@ -116,7 +116,7 @@ State::State(OverlayDB const& _db, BaseState _bs, Address _coinbaseAddress):
PopulationStatistics State::populateFromChain(BlockChain const& _bc, h256 const& _h, ImportRequirements::value _ir) PopulationStatistics State::populateFromChain(BlockChain const& _bc, h256 const& _h, ImportRequirements::value _ir)
{ {
PopulationStatistics ret; PopulationStatistics ret { 0.0, 0.0 };
if (!_bc.isKnown(_h)) if (!_bc.isKnown(_h))
{ {

24
libethereum/VerifiedBlock.h

@ -43,8 +43,32 @@ struct VerifiedBlockRef
/// @brief Verified block info, combines block data and verified info/transactions /// @brief Verified block info, combines block data and verified info/transactions
struct VerifiedBlock struct VerifiedBlock
{ {
VerifiedBlock() {};
VerifiedBlock(BlockInfo&& _bi)
{
verified.info = _bi;
}
VerifiedBlock(VerifiedBlock&& _other):
verified(std::move(_other.verified)),
blockData(std::move(_other.blockData))
{
}
VerifiedBlock& operator=(VerifiedBlock&& _other)
{
verified = (std::move(_other.verified));
blockData = (std::move(_other.blockData));
return *this;
}
VerifiedBlockRef verified; ///< Verified block structures VerifiedBlockRef verified; ///< Verified block structures
bytes blockData; ///< Block data bytes blockData; ///< Block data
private:
VerifiedBlock(VerifiedBlock const&) = delete;
VerifiedBlock operator=(VerifiedBlock const&) = delete;
}; };
using VerifiedBlocks = std::vector<VerifiedBlock>; using VerifiedBlocks = std::vector<VerifiedBlock>;

Loading…
Cancel
Save