Browse Source

Vitalik's diff changes.

cl-refactor
Gav Wood 11 years ago
parent
commit
cd7f330551
  1. 2
      libethereum/BlockChain.cpp
  2. 4
      libethereum/BlockInfo.cpp
  3. 2
      libethereum/Dagger.h

2
libethereum/BlockChain.cpp

@ -85,7 +85,7 @@ BlockChain::BlockChain(std::string _path, bool _killExisting)
if (!details(m_genesisHash))
{
// Insert details of genesis block.
m_details[m_genesisHash] = BlockDetails(0, (u256)1 << 36, h256(), {});
m_details[m_genesisHash] = BlockDetails(0, (u256)1 << 32, h256(), {});
auto r = m_details[m_genesisHash].rlp();
m_detailsDB->Put(m_writeOptions, ldb::Slice((char const*)&m_genesisHash, 32), (ldb::Slice)eth::ref(r));
}

4
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 << ((uint)1 << 36) << (uint)0 << string() << (uint)0;
block.appendList(9) << h256() << sha3EmptyList << h160() << sha3(RLPNull) << sha3EmptyList << ((uint)1 << 32) << (uint)0 << string() << (uint)0;
block.appendRaw(RLPEmptyList);
block.appendRaw(RLPEmptyList);
return block.out();
@ -109,7 +109,7 @@ void BlockInfo::verifyInternals(bytesConstRef _block) const
u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const
{
if (!parentHash)
return (u256)1 << 36;
return (u256)1 << 32;
else
return timestamp >= _parent.timestamp + 42 ? _parent.difficulty - (_parent.difficulty >> 10) : (_parent.difficulty + (_parent.difficulty >> 10));
}

2
libethereum/Dagger.h

@ -24,7 +24,7 @@ struct MineInfo
class Dagger
{
public:
static h256 eval(h256 const& _root, u256 const& _nonce) { h256 b = (h256)((u256)_root ^ _nonce); return sha3(bytesConstRef((byte const*)&b, 32)); }
static h256 eval(h256 const& _root, u256 const& _nonce) { h256 b[2] = { _root, (h256)_nonce }; return sha3(bytesConstRef((byte const*)&b[0], 64)); }
static bool verify(h256 const& _root, u256 const& _nonce, u256 const& _difficulty) { return (bigint)(u256)eval(_root, _nonce) <= (bigint(1) << 256) / _difficulty; }
MineInfo mine(u256& o_solution, h256 const& _root, u256 const& _difficulty, uint _msTimeout = 100, bool const& _continue = bool(true));

Loading…
Cancel
Save