From bdeaf497b0d835995106db36978109278d48cbc0 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 13 Feb 2014 14:27:07 +0000 Subject: [PATCH] Remove some debug output. Make hash construction safer. --- libethereum/BlockChain.cpp | 2 +- libethereum/Common.cpp | 2 +- libethereum/Common.h | 3 ++- test/main.cpp | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 6b9e0715c..146d09f0a 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -212,7 +212,7 @@ void BlockChain::checkConsistency() for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().size() == 32) { - h256 h((byte const*)it->key().data()); + h256 h((byte const*)it->key().data(), h256::ConstructFromPointer); auto dh = details(h); auto p = dh.parent; if (p != h256()) diff --git a/libethereum/Common.cpp b/libethereum/Common.cpp index ad5d491f4..17a8b21f3 100644 --- a/libethereum/Common.cpp +++ b/libethereum/Common.cpp @@ -38,7 +38,7 @@ using namespace std; using namespace eth; -#define ETH_ADDRESS_DEBUG 1 +//#define ETH_ADDRESS_DEBUG 1 // Logging int eth::g_logVerbosity = 8; diff --git a/libethereum/Common.h b/libethereum/Common.h index ff9bedd5b..ab3871ce1 100644 --- a/libethereum/Common.h +++ b/libethereum/Common.h @@ -78,11 +78,12 @@ class FixedHash public: enum { size = N }; + enum ConstructFromPointerType { ConstructFromPointer }; FixedHash() { m_data.fill(0); } FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } explicit FixedHash(bytes const& _b) { memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } - explicit FixedHash(byte const* _bs) { memcpy(m_data.data(), _bs, N); } + explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } operator Arith() const { return fromBigEndian(m_data); } diff --git a/test/main.cpp b/test/main.cpp index 9caaaa14c..68daeddb9 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -41,10 +41,10 @@ int main(int argc, char** argv) std::cout << asHex(s.out()) << std::endl; std::cout << sha3(s.out()) << std::endl;*/ -// hexPrefixTest(); -// rlpTest(); -// trieTest(); -// daggerTest(); + hexPrefixTest(); + rlpTest(); + trieTest(); + daggerTest(); cryptoTest(); // stateTest(); // peerTest(argc, argv);