Browse Source

BlockChainTests mining

cl-refactor
Dimitry 9 years ago
parent
commit
238f17e79b
  1. 2
      libethereum/Block.cpp
  2. 5
      libethereum/Block.h
  3. 6
      test/libethereum/blockchain.cpp

2
libethereum/Block.cpp

@ -709,7 +709,7 @@ bool Block::sealBlock(bytesConstRef _header)
ret.appendRaw(m_currentTxs); ret.appendRaw(m_currentTxs);
ret.appendRaw(m_currentUncles); ret.appendRaw(m_currentUncles);
ret.swapOut(m_currentBytes); ret.swapOut(m_currentBytes);
m_currentBlock = BlockInfo(_header, CheckNothing, h256(), HeaderData); m_currentBlock = Ethash::BlockHeader(_header, CheckNothing, h256(), HeaderData);
cnote << "Mined " << m_currentBlock.hash() << "(parent: " << m_currentBlock.parentHash() << ")"; cnote << "Mined " << m_currentBlock.hash() << "(parent: " << m_currentBlock.parentHash() << ")";
// TODO: move into Sealer // TODO: move into Sealer
StructuredLogger::minedNewBlock( StructuredLogger::minedNewBlock(

5
libethereum/Block.h

@ -29,6 +29,7 @@
#include <libdevcrypto/OverlayDB.h> #include <libdevcrypto/OverlayDB.h>
#include <libethcore/Exceptions.h> #include <libethcore/Exceptions.h>
#include <libethcore/BlockInfo.h> #include <libethcore/BlockInfo.h>
#include <libethcore/Ethash.h>
#include <libethcore/Miner.h> #include <libethcore/Miner.h>
#include <libevm/ExtVMFace.h> #include <libevm/ExtVMFace.h>
#include "Account.h" #include "Account.h"
@ -252,7 +253,7 @@ public:
bytes const& blockData() const { return m_currentBytes; } bytes const& blockData() const { return m_currentBytes; }
/// Get the header information on the present block. /// Get the header information on the present block.
BlockInfo const& info() const { return m_currentBlock; } Ethash::BlockHeader const& info() const { return m_currentBlock; }
private: private:
@ -288,7 +289,7 @@ private:
State m_precommit; ///< State at the point immediately prior to rewards. State m_precommit; ///< State at the point immediately prior to rewards.
BlockInfo m_previousBlock; ///< The previous block's information. BlockInfo m_previousBlock; ///< The previous block's information.
BlockInfo m_currentBlock; ///< The current block's information. Ethash::BlockHeader m_currentBlock; ///< The current block's information.
bytes m_currentBytes; ///< The current block. bytes m_currentBytes; ///< The current block.
bool m_committedToMine = false; ///< Have we committed to mine on the present m_currentBlock? bool m_committedToMine = false; ///< Have we committed to mine on the present m_currentBlock?

6
test/libethereum/blockchain.cpp

@ -128,12 +128,12 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
vBiBlocks.clear(); vBiBlocks.clear();
vBiBlocks.push_back(biGenesisBlock); vBiBlocks.push_back(biGenesisBlock);
TransientDirectory td_stateDB, td_bc; TransientDirectory td_bc;
TransientDirectory td_stateDB;
FullBlockChain<Ethash> bc(rlpGenesisBlock.out(), AccountMap(), td_bc.path(), WithExisting::Kill); FullBlockChain<Ethash> bc(rlpGenesisBlock.out(), AccountMap(), td_bc.path(), WithExisting::Kill);
OverlayDB database (State::openDB(td_stateDB.path(), h256{}, WithExisting::Kill)); OverlayDB database (State::openDB(td_stateDB.path(), h256{}, WithExisting::Kill));
State state(database, BaseState::Empty); State state(database, BaseState::Empty);
Block block(database, BaseState::Empty, biGenesisBlock.beneficiary());
state = importer.m_statePre; state = importer.m_statePre;
state.commit(); state.commit();
@ -188,7 +188,9 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
cnote << "error in importing uncle! This produces an invalid block (May be by purpose for testing)."; cnote << "error in importing uncle! This produces an invalid block (May be by purpose for testing).";
} }
} }
bc.sync(uncleBlockQueue, state.db(), 4); bc.sync(uncleBlockQueue, state.db(), 4);
Block block = bc.genesisBlock(state.db());
//mine a new block on top of previously imported //mine a new block on top of previously imported
try try

Loading…
Cancel
Save