Browse Source

Don't check nonce by default.

cl-refactor
Gav Wood 10 years ago
parent
commit
a33de145e7
  1. 6
      cmake/EthCompilerSettings.cmake
  2. 4
      libethcore/BlockInfo.cpp
  3. 14
      libethcore/BlockInfo.h
  4. 19
      libethereum/BlockChain.cpp

6
cmake/EthCompilerSettings.cmake

@ -11,7 +11,11 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
set(ETH_SHARED 1)
if (PROFILING)
set(CMAKE_CXX_FLAGS "-pg -g ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-g ${CMAKE_CXX_FLAGS}")
add_definitions(-DETH_PROFILING_GPERF)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
# set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -lprofiler")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lprofiler")
endif ()
execute_process(

4
libethcore/BlockInfo.cpp

@ -69,10 +69,10 @@ h256 const& BlockInfo::seedHash() const
return m_seedHash;
}
BlockInfo BlockInfo::fromHeader(bytesConstRef _block, Strictness _s)
BlockInfo BlockInfo::fromHeader(bytesConstRef _header, Strictness _s)
{
BlockInfo ret;
ret.populateFromHeader(RLP(_block), _s);
ret.populateFromHeader(RLP(_header), _s);
return ret;
}

14
libethcore/BlockInfo.h

@ -86,14 +86,14 @@ public:
Nonce nonce;
BlockInfo();
explicit BlockInfo(bytes const& _block, Strictness _s = CheckEverything): BlockInfo(&_block, _s) {}
explicit BlockInfo(bytesConstRef _block, Strictness _s = CheckEverything);
explicit BlockInfo(bytes const& _block, Strictness _s = IgnoreNonce): BlockInfo(&_block, _s) {}
explicit BlockInfo(bytesConstRef _block, Strictness _s = IgnoreNonce);
static h256 headerHash(bytes const& _block) { return headerHash(&_block); }
static h256 headerHash(bytesConstRef _block);
static BlockInfo fromHeader(bytes const& _block, Strictness _s = CheckEverything) { return fromHeader(bytesConstRef(&_block), _s); }
static BlockInfo fromHeader(bytesConstRef _block, Strictness _s = CheckEverything);
static BlockInfo fromHeader(bytes const& _header, Strictness _s = IgnoreNonce) { return fromHeader(bytesConstRef(&_header), _s); }
static BlockInfo fromHeader(bytesConstRef _header, Strictness _s = IgnoreNonce);
explicit operator bool() const { return timestamp != Invalid256; }
@ -119,9 +119,9 @@ public:
void setEmpty();
void populateFromHeader(RLP const& _header, Strictness _s = CheckEverything);
void populate(bytesConstRef _block, Strictness _s = CheckEverything);
void populate(bytes const& _block, Strictness _s = CheckEverything) { populate(&_block, _s); }
void populateFromHeader(RLP const& _header, Strictness _s = IgnoreNonce);
void populate(bytesConstRef _block, Strictness _s = IgnoreNonce);
void populate(bytes const& _block, Strictness _s = IgnoreNonce) { populate(&_block, _s); }
void verifyInternals(bytesConstRef _block) const;
void verifyParent(BlockInfo const& _parent) const;
void populateFromParent(BlockInfo const& parent);

19
libethereum/BlockChain.cpp

@ -155,7 +155,9 @@ void BlockChain::open(std::string const& _path, WithExisting _we)
m_extrasDB->Put(m_writeOptions, toSlice(m_genesisHash, ExtraDetails), (ldb::Slice)dev::ref(r));
}
#if ETH_PARANOIA
checkConsistency();
#endif
// TODO: Implement ability to rebuild details map from DB.
std::string l;
@ -175,10 +177,15 @@ void BlockChain::close()
m_blocks.clear();
}
#include <gperftools/profiler.h>
#define IGNORE_EXCEPTIONS(X) try { X; } catch (...) {}
void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned, unsigned)> const& _progress)
{
#if ETH_PROFILING_GPERF
ProfilerStart("BlockChain_rebuild.log");
#endif
unsigned originalNumber = number();
// Keep extras DB around, but under a temp name
@ -206,10 +213,14 @@ void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned,
m_lastBlockHash = genesisHash();
h256 lastHash = genesisHash();
boost::timer t;
for (unsigned d = 1; d < originalNumber; ++d)
{
if (originalNumber > 1000)
exit(0);
if (!(d % 1000))
{
cerr << "\n1000 blocks in " << t.elapsed() << "s = " << (1000.0 / t.elapsed()) << "b/s" << endl;
t.restart();
}
try
{
bytes b = block(queryExtras<BlockHash, ExtraBlockHash>(h256(u256(d)), m_blockHashes, x_blockHashes, NullBlockHash, oldExtrasDB).value);
@ -233,6 +244,10 @@ void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned,
_progress(d, originalNumber);
}
#if ETH_PROFILING_GPERF
ProfilerStop();
#endif
delete oldExtrasDB;
boost::filesystem::remove_all(_path + "/details.old");
}

Loading…
Cancel
Save