Browse Source

Remove some debug output.

Make hash construction safer.
cl-refactor
Gav Wood 11 years ago
parent
commit
bdeaf497b0
  1. 2
      libethereum/BlockChain.cpp
  2. 2
      libethereum/Common.cpp
  3. 3
      libethereum/Common.h
  4. 8
      test/main.cpp

2
libethereum/BlockChain.cpp

@ -212,7 +212,7 @@ void BlockChain::checkConsistency()
for (it->SeekToFirst(); it->Valid(); it->Next()) for (it->SeekToFirst(); it->Valid(); it->Next())
if (it->key().size() == 32) 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 dh = details(h);
auto p = dh.parent; auto p = dh.parent;
if (p != h256()) if (p != h256())

2
libethereum/Common.cpp

@ -38,7 +38,7 @@
using namespace std; using namespace std;
using namespace eth; using namespace eth;
#define ETH_ADDRESS_DEBUG 1 //#define ETH_ADDRESS_DEBUG 1
// Logging // Logging
int eth::g_logVerbosity = 8; int eth::g_logVerbosity = 8;

3
libethereum/Common.h

@ -78,11 +78,12 @@ class FixedHash
public: public:
enum { size = N }; enum { size = N };
enum ConstructFromPointerType { ConstructFromPointer };
FixedHash() { m_data.fill(0); } FixedHash() { m_data.fill(0); }
FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); }
explicit FixedHash(bytes const& _b) { memcpy(m_data.data(), _b.data(), std::min<uint>(_b.size(), N)); } explicit FixedHash(bytes const& _b) { memcpy(m_data.data(), _b.data(), std::min<uint>(_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<Arith>(m_data); } operator Arith() const { return fromBigEndian<Arith>(m_data); }

8
test/main.cpp

@ -41,10 +41,10 @@ int main(int argc, char** argv)
std::cout << asHex(s.out()) << std::endl; std::cout << asHex(s.out()) << std::endl;
std::cout << sha3(s.out()) << std::endl;*/ std::cout << sha3(s.out()) << std::endl;*/
// hexPrefixTest(); hexPrefixTest();
// rlpTest(); rlpTest();
// trieTest(); trieTest();
// daggerTest(); daggerTest();
cryptoTest(); cryptoTest();
// stateTest(); // stateTest();
// peerTest(argc, argv); // peerTest(argc, argv);

Loading…
Cancel
Save