Browse Source

Changed genesis block to reflect root of empty trie as null.

cl-refactor
Gav Wood 11 years ago
parent
commit
5185e6a6ef
  1. 2
      libethereum/BlockInfo.cpp
  2. 3
      libethereum/TrieDB.cpp
  3. 4
      libethereum/TrieDB.h
  4. 4
      test/main.cpp

2
libethereum/BlockInfo.cpp

@ -42,7 +42,7 @@ bytes BlockInfo::createGenesisBlock()
{
RLPStream block(3);
auto sha3EmptyList = sha3(RLPEmptyList);
block.appendList(9) << h256() << sha3EmptyList << h160() << sha3(RLPNull) << sha3EmptyList << c_genesisDifficulty << (uint)0 << string() << (uint)0;
block.appendList(9) << h256() << sha3EmptyList << h160() << h256() << sha3EmptyList << c_genesisDifficulty << (uint)0 << string() << (uint)0;
block.appendRaw(RLPEmptyList);
block.appendRaw(RLPEmptyList);
return block.out();

3
libethereum/TrieDB.cpp

@ -26,4 +26,7 @@ using namespace eth;
namespace eth
{
const h256 c_shaNull = sha3("");
}

4
libethereum/TrieDB.h

@ -94,6 +94,8 @@ private:
#pragma warning(disable:4100) // disable warnings so it compiles
#endif
extern const h256 c_shaNull;
/**
* @brief Merkle Patricia Tree "Trie": a modifed base-16 Radix tree.
* This version uses an LDB backend
@ -111,7 +113,7 @@ public:
void init();
void setRoot(h256 _root) { m_root = _root; }
h256 root() const { return m_root; }
h256 root() const { return m_root == c_shaNull ? h256() : m_root; } // patch the root in the case of the empty trie. TODO: handle this properly.
void debugPrint() {}

4
test/main.cpp

@ -35,11 +35,11 @@ using namespace eth;
int main(int argc, char** argv)
{
/*RLPStream s;
RLPStream s;
BlockInfo::genesis().fillStream(s, false);
std::cout << RLP(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();
// rlpTest();

Loading…
Cancel
Save