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) set(ETH_SHARED 1)
if (PROFILING) 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 () endif ()
execute_process( execute_process(

4
libethcore/BlockInfo.cpp

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

14
libethcore/BlockInfo.h

@ -86,14 +86,14 @@ public:
Nonce nonce; Nonce nonce;
BlockInfo(); BlockInfo();
explicit BlockInfo(bytes const& _block, Strictness _s = CheckEverything): BlockInfo(&_block, _s) {} explicit BlockInfo(bytes const& _block, Strictness _s = IgnoreNonce): BlockInfo(&_block, _s) {}
explicit BlockInfo(bytesConstRef _block, Strictness _s = CheckEverything); explicit BlockInfo(bytesConstRef _block, Strictness _s = IgnoreNonce);
static h256 headerHash(bytes const& _block) { return headerHash(&_block); } static h256 headerHash(bytes const& _block) { return headerHash(&_block); }
static h256 headerHash(bytesConstRef _block); static h256 headerHash(bytesConstRef _block);
static BlockInfo fromHeader(bytes const& _block, Strictness _s = CheckEverything) { return fromHeader(bytesConstRef(&_block), _s); } static BlockInfo fromHeader(bytes const& _header, Strictness _s = IgnoreNonce) { return fromHeader(bytesConstRef(&_header), _s); }
static BlockInfo fromHeader(bytesConstRef _block, Strictness _s = CheckEverything); static BlockInfo fromHeader(bytesConstRef _header, Strictness _s = IgnoreNonce);
explicit operator bool() const { return timestamp != Invalid256; } explicit operator bool() const { return timestamp != Invalid256; }
@ -119,9 +119,9 @@ public:
void setEmpty(); void setEmpty();
void populateFromHeader(RLP const& _header, Strictness _s = CheckEverything); void populateFromHeader(RLP const& _header, Strictness _s = IgnoreNonce);
void populate(bytesConstRef _block, Strictness _s = CheckEverything); void populate(bytesConstRef _block, Strictness _s = IgnoreNonce);
void populate(bytes const& _block, Strictness _s = CheckEverything) { populate(&_block, _s); } void populate(bytes const& _block, Strictness _s = IgnoreNonce) { populate(&_block, _s); }
void verifyInternals(bytesConstRef _block) const; void verifyInternals(bytesConstRef _block) const;
void verifyParent(BlockInfo const& _parent) const; void verifyParent(BlockInfo const& _parent) const;
void populateFromParent(BlockInfo const& parent); 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)); m_extrasDB->Put(m_writeOptions, toSlice(m_genesisHash, ExtraDetails), (ldb::Slice)dev::ref(r));
} }
#if ETH_PARANOIA
checkConsistency(); checkConsistency();
#endif
// TODO: Implement ability to rebuild details map from DB. // TODO: Implement ability to rebuild details map from DB.
std::string l; std::string l;
@ -175,10 +177,15 @@ void BlockChain::close()
m_blocks.clear(); m_blocks.clear();
} }
#include <gperftools/profiler.h>
#define IGNORE_EXCEPTIONS(X) try { X; } catch (...) {} #define IGNORE_EXCEPTIONS(X) try { X; } catch (...) {}
void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned, unsigned)> const& _progress) 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(); unsigned originalNumber = number();
// Keep extras DB around, but under a temp name // 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(); m_lastBlockHash = genesisHash();
h256 lastHash = genesisHash(); h256 lastHash = genesisHash();
boost::timer t;
for (unsigned d = 1; d < originalNumber; ++d) for (unsigned d = 1; d < originalNumber; ++d)
{ {
if (originalNumber > 1000) if (!(d % 1000))
exit(0); {
cerr << "\n1000 blocks in " << t.elapsed() << "s = " << (1000.0 / t.elapsed()) << "b/s" << endl;
t.restart();
}
try try
{ {
bytes b = block(queryExtras<BlockHash, ExtraBlockHash>(h256(u256(d)), m_blockHashes, x_blockHashes, NullBlockHash, oldExtrasDB).value); 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); _progress(d, originalNumber);
} }
#if ETH_PROFILING_GPERF
ProfilerStop();
#endif
delete oldExtrasDB; delete oldExtrasDB;
boost::filesystem::remove_all(_path + "/details.old"); boost::filesystem::remove_all(_path + "/details.old");
} }

Loading…
Cancel
Save