Browse Source

fixed block memory management

cl-refactor
arkpar 10 years ago
parent
commit
49a8617261
  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
}
#if ETH_CATCH
catch (BadRoot& ex)
catch (BadRoot&)
{
cwarn << "BadRoot error. Retrying import later.";
BOOST_THROW_EXCEPTION(FutureTime());

6
libethereum/BlockQueue.cpp

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

2
libethereum/State.cpp

@ -117,7 +117,7 @@ State::State(OverlayDB const& _db, BaseState _bs, Address _coinbaseAddress):
PopulationStatistics State::populateFromChain(BlockChain const& _bc, h256 const& _h, ImportRequirements::value _ir)
{
PopulationStatistics ret;
PopulationStatistics ret { 0.0, 0.0 };
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
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
bytes blockData; ///< Block data
private:
VerifiedBlock(VerifiedBlock const&) = delete;
VerifiedBlock operator=(VerifiedBlock const&) = delete;
};
using VerifiedBlocks = std::vector<VerifiedBlock>;

Loading…
Cancel
Save