Browse Source

contains() gets moved to CommonData.h

- It also now uses std::find()
cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
b9b1936477
  1. 6
      libdevcore/CommonData.h
  2. 4
      libethereum/BlockChain.cpp

6
libdevcore/CommonData.h

@ -334,4 +334,10 @@ std::vector<T> keysOf(std::unordered_map<T, U> const& _m)
return ret;
}
template <class T, class V>
bool contains(T const& _t, V const& _v)
{
return std::end(_t) != std::find(std::begin(_t), std::end(_t), _v);
}
}

4
libethereum/BlockChain.cpp

@ -24,7 +24,7 @@
#if ETH_PROFILING_GPERF
#include <gperftools/profiler.h>
#endif
#include <algorithm>
#include <boost/timer.hpp>
#include <boost/filesystem.hpp>
#include <test/JsonSpiritHeaders.h>
@ -942,7 +942,7 @@ void BlockChain::checkConsistency()
if (p != h256() && p != m_genesisHash) // TODO: for some reason the genesis details with the children get squished. not sure why.
{
auto dp = details(p);
if (asserts(end(dp.children) != find(begin(dp.children), end(dp.children), h)))
if (asserts(contains(dp.children, h)))
{
cnote << "Apparently the database is corrupt. Not much we can do at this stage...";
}

Loading…
Cancel
Save