Browse Source

mix working

cl-refactor
arkpar 10 years ago
committed by Gav Wood
parent
commit
f7500218c8
  1. 28
      CMakeLists.txt
  2. 55
      alethzero/MainWin.cpp
  3. 4
      alethzero/MiningView.cpp
  4. 4
      alethzero/MiningView.h
  5. 4
      exp/CMakeLists.txt
  6. 1
      libethereum/BlockChain.cpp
  7. 3
      libtestutils/BlockChainLoader.cpp
  8. 2
      libtestutils/StateLoader.cpp
  9. 2
      libtestutils/StateLoader.h
  10. 8
      libweb3jsonrpc/JsonHelper.cpp
  11. 2
      libweb3jsonrpc/WebThreeStubServer.cpp
  12. 4
      libweb3jsonrpc/WebThreeStubServer.h
  13. 2
      libwebthree/WebThree.cpp
  14. 4
      mix/ClientModel.cpp
  15. 36
      mix/MixClient.cpp
  16. 36
      mix/MixClient.h

28
CMakeLists.txt

@ -403,13 +403,13 @@ if (TOOLS)
endif ()
if (JSONRPC AND GENERAL)
# add_subdirectory(libweb3jsonrpc)
add_subdirectory(libweb3jsonrpc)
endif ()
if (JSCONSOLE)
# add_subdirectory(libjsengine)
# add_subdirectory(libjsconsole)
# add_subdirectory(ethconsole)
add_subdirectory(libjsengine)
add_subdirectory(libjsconsole)
add_subdirectory(ethconsole)
endif ()
if (NOT WIN32)
@ -437,31 +437,31 @@ add_subdirectory(libethcore)
if (GENERAL)
add_subdirectory(libevm)
add_subdirectory(libethereum)
# add_subdirectory(libwebthree)
add_subdirectory(libwebthree)
endif ()
if (MINER OR TOOLS)
# add_subdirectory(ethminer)
add_subdirectory(ethminer)
endif ()
if (ETHKEY OR TOOLS)
# add_subdirectory(ethkey)
add_subdirectory(ethkey)
endif ()
if (TESTS)
# add_subdirectory(libtestutils)
# add_subdirectory(test)
add_subdirectory(libtestutils)
add_subdirectory(test)
if (JSONRPC)
# add_subdirectory(ethrpctest)
add_subdirectory(ethrpctest)
endif ()
endif ()
if (TOOLS)
# add_subdirectory(rlp)
# add_subdirectory(abi)
# add_subdirectory(ethvm)
# add_subdirectory(eth)
add_subdirectory(rlp)
add_subdirectory(abi)
add_subdirectory(ethvm)
add_subdirectory(eth)
if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug")
add_subdirectory(exp)

55
alethzero/MainWin.cpp

@ -189,9 +189,9 @@ Main::Main(QWidget *parent) :
#endif
m_servers.append(QString::fromStdString(Host::pocHost() + ":30303"));
cerr << "State root: " << CanonBlockChain::genesis().stateRoot() << endl;
auto block = CanonBlockChain::createGenesisBlock();
cerr << "Block Hash: " << CanonBlockChain::genesis().hash() << endl;
cerr << "State root: " << CanonBlockChain<Ethash>::genesis().stateRoot() << endl;
auto block = CanonBlockChain<Ethash>::createGenesisBlock();
cerr << "Block Hash: " << CanonBlockChain<Ethash>::genesis().hash() << endl;
cerr << "Block RLP: " << RLP(block) << endl;
cerr << "Block Hex: " << toHex(block) << endl;
cerr << "eth Network protocol version: " << eth::c_protocolVersion << endl;
@ -208,13 +208,14 @@ Main::Main(QWidget *parent) :
statusBar()->addPermanentWidget(ui->chainStatus);
statusBar()->addPermanentWidget(ui->blockCount);
ui->blockCount->setText(QString("PV%1.%2 D%3 %4-%5 v%6").arg(eth::c_protocolVersion).arg(eth::c_minorProtocolVersion).arg(c_databaseVersion).arg(QString::fromStdString(ethereum()->sealEngine()->name())).arg(ethereum()->sealEngine()->revision()).arg(dev::Version));
QSettings s("ethereum", "alethzero");
m_networkConfig = s.value("peers").toByteArray();
bytesConstRef network((byte*)m_networkConfig.data(), m_networkConfig.size());
m_webThree.reset(new WebThreeDirect(string("AlethZero/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir(), WithExisting::Trust, {"eth"/*, "shh"*/}, p2p::NetworkPreferences(), network));
ui->blockCount->setText(QString("PV%1.%2 D%3 %4-%5 v%6").arg(eth::c_protocolVersion).arg(eth::c_minorProtocolVersion).arg(c_databaseVersion).arg(QString::fromStdString(ethereum()->sealEngine()->name())).arg(ethereum()->sealEngine()->revision()).arg(dev::Version));
m_httpConnector.reset(new jsonrpc::HttpServer(SensibleHttpPort, "", "", dev::SensibleHttpThreads));
auto w3ss = new OurWebThreeStubServer(*m_httpConnector, this);
m_server.reset(w3ss);
@ -1124,7 +1125,7 @@ void Main::refreshMining()
QString t;
if (gp.first != EthashAux::NotGenerating)
t = QString("DAG for #%1-#%2: %3% complete; ").arg(gp.first).arg(gp.first + ETHASH_EPOCH_LENGTH - 1).arg(gp.second);
MiningProgress p = ethereum()->miningProgress();
WorkingProgress p = ethereum()->miningProgress();
ui->mineStatus->setText(t + (ethereum()->isMining() ? p.hashes > 0 ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Awaiting DAG" : "Not mining"));
if (ethereum()->isMining() && p.hashes > 0)
{
@ -1629,7 +1630,7 @@ void Main::on_transactionQueue_currentItemChanged()
else
s << "<div>Log Bloom: <b><i>Uneventful</i></b></div>";
s << "<div>Gas Used: <b>" << receipt.gasUsed() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot()().abridged() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot().abridged() << "</b></div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";
@ -1699,7 +1700,7 @@ void Main::on_blocks_currentItemChanged()
auto details = ethereum()->blockChain().details(h);
auto blockData = ethereum()->blockChain().block(h);
auto block = RLP(blockData);
BlockInfo info(blockData);
Ethash::BlockHeader info(blockData);
stringstream s;
@ -1709,21 +1710,21 @@ void Main::on_blocks_currentItemChanged()
time_t rawTime = (time_t)(uint64_t)info.timestamp();
strftime(timestamp, 64, "%c", localtime(&rawTime));
s << "<h3>" << h << "</h3>";
s << "<h4>#" << info.number;
s << "<h4>#" << info.number();
s << "&nbsp;&emsp;&nbsp;<b>" << timestamp << "</b></h4>";
s << "<div>D/TD: <b>" << info.difficulty << "</b>/<b>" << details.totalDifficulty << "</b> = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty) << "</div>";
s << "<div>D/TD: <b>" << info.difficulty() << "</b>/<b>" << details.totalDifficulty << "</b> = 2^" << log2((double)info.difficulty()) << "/2^" << log2((double)details.totalDifficulty) << "</div>";
s << "&nbsp;&emsp;&nbsp;Children: <b>" << details.children.size() << "</b></div>";
s << "<div>Gas used/limit: <b>" << info.gasUsed << "</b>/<b>" << info.gasLimit << "</b>" << "</div>";
s << "<div>Gas used/limit: <b>" << info.gasUsed() << "</b>/<b>" << info.gasLimit() << "</b>" << "</div>";
s << "<div>Beneficiary: <b>" << htmlEscaped(pretty(info.coinbaseAddress())) << " " << info.coinbaseAddress() << "</b>" << "</div>";
s << "<div>Seed hash: <b>" << info.seedHash() << "</b>" << "</div>";
s << "<div>Mix hash: <b>" << info.mixHash << "</b>" << "</div>";
s << "<div>Nonce: <b>" << info.nonce << "</b>" << "</div>";
s << "<div>Hash w/o nonce: <b>" << info.headerHash(WithoutProof) << "</b>" << "</div>";
s << "<div>Difficulty: <b>" << info.difficulty << "</b>" << "</div>";
if (info.number)
{
auto e = EthashAux::eval(info);
s << "<div>Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
s << "<div>Mix hash: <b>" << info.mixHash() << "</b>" << "</div>";
s << "<div>Nonce: <b>" << info.nonce() << "</b>" << "</div>";
s << "<div>Hash w/o nonce: <b>" << info.hashWithout() << "</b>" << "</div>";
s << "<div>Difficulty: <b>" << info.difficulty() << "</b>" << "</div>";
if (info.number())
{
auto e = EthashAux::eval(info.seedHash(), info.hashWithout(), info.nonce());
s << "<div>Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty()) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
s << "<div>Parent: <b>" << info.parentHash() << "</b>" << "</div>";
}
else
@ -1740,19 +1741,19 @@ void Main::on_blocks_currentItemChanged()
s << "<div>Uncles: <b>" << block[2].itemCount() << "</b> @<b>" << info.sha3Uncles() << "</b>" << "</div>";
for (auto u: block[2])
{
BlockInfo uncle = BlockInfo::fromHeader(u.data());
Ethash::BlockHeader uncle(u.data(), CheckNothing, h256(), HeaderData);
char const* line = "<div><span style=\"margin-left: 2em\">&nbsp;</span>";
s << line << "Hash: <b>" << uncle.hash() << "</b>" << "</div>";
s << line << "Parent: <b>" << uncle.parentHash() << "</b>" << "</div>";
s << line << "Number: <b>" << uncle.number << "</b>" << "</div>";
s << line << "Number: <b>" << uncle.number() << "</b>" << "</div>";
s << line << "Coinbase: <b>" << htmlEscaped(pretty(uncle.coinbaseAddress())) << " " << uncle.coinbaseAddress() << "</b>" << "</div>";
s << line << "Seed hash: <b>" << uncle.seedHash() << "</b>" << "</div>";
s << line << "Mix hash: <b>" << uncle.mixHash << "</b>" << "</div>";
s << line << "Nonce: <b>" << uncle.nonce << "</b>" << "</div>";
s << line << "Mix hash: <b>" << uncle.mixHash() << "</b>" << "</div>";
s << line << "Nonce: <b>" << uncle.nonce() << "</b>" << "</div>";
s << line << "Hash w/o nonce: <b>" << uncle.headerHash(WithoutProof) << "</b>" << "</div>";
s << line << "Difficulty: <b>" << uncle.difficulty << "</b>" << "</div>";
auto e = EthashAux::eval(uncle);
s << line << "Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
s << line << "Difficulty: <b>" << uncle.difficulty() << "</b>" << "</div>";
auto e = EthashAux::eval(uncle.seedHash(), uncle.hashWithout(), uncle.nonce());
s << line << "Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / uncle.difficulty()) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
}
if (info.parentHash())
s << "<div>Pre: <b>" << BlockInfo(ethereum()->blockChain().block(info.parentHash())).stateRoot() << "</b>" << "</div>";
@ -1764,7 +1765,7 @@ void Main::on_blocks_currentItemChanged()
unsigned ii = 0;
for (auto const& i: block[1])
{
s << "<div>" << sha3(i.data()).abridged() << ": <b>" << receipts.receipts[ii].stateRoot()() << "</b> [<b>" << receipts.receipts[ii].gasUsed() << "</b> used]" << "</div>";
s << "<div>" << sha3(i.data()).abridged() << ": <b>" << receipts.receipts[ii].stateRoot() << "</b> [<b>" << receipts.receipts[ii].gasUsed() << "</b> used]" << "</div>";
++ii;
}
s << "<div>Post: <b>" << info.stateRoot() << "</b>" << "</div>";
@ -1807,7 +1808,7 @@ void Main::on_blocks_currentItemChanged()
else
s << "<div>Log Bloom: <b><i>Uneventful</i></b></div>";
s << "<div>Gas Used: <b>" << receipt.gasUsed() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot()().abridged() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot().abridged() << "</b></div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";

4
alethzero/MiningView.cpp

@ -36,7 +36,7 @@ using namespace dev::eth;
// types
using dev::eth::MineInfo;
using dev::eth::MiningProgress;
using dev::eth::WorkingProgress;
// functions
using dev::toString;
@ -50,7 +50,7 @@ MiningView::MiningView(QWidget* _p): QWidget(_p)
{
}
void MiningView::appendStats(list<MineInfo> const& _i, MiningProgress const& _p)
void MiningView::appendStats(list<MineInfo> const& _i, WorkingProgress const& _p)
{
(void)_p;
if (_i.empty())

4
alethzero/MiningView.h

@ -42,14 +42,14 @@ class MiningView: public QWidget
public:
MiningView(QWidget* _p = nullptr);
void appendStats(std::list<dev::eth::MineInfo> const& _l, dev::eth::MiningProgress const& _p);
void appendStats(std::list<dev::eth::MineInfo> const& _l, dev::eth::WorkingProgress const& _p);
void resetStats();
protected:
virtual void paintEvent(QPaintEvent*);
private:
dev::eth::MiningProgress m_progress;
dev::eth::WorkingProgress m_progress;
unsigned m_duration = 300;
std::vector<float> m_values;
std::vector<float> m_bests;

4
exp/CMakeLists.txt

@ -18,10 +18,10 @@ if (READLINE_FOUND)
endif()
if (JSONRPC)
# target_link_libraries(${EXECUTABLE} web3jsonrpc)
target_link_libraries(${EXECUTABLE} web3jsonrpc)
endif()
#target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} ethereum)
target_link_libraries(${EXECUTABLE} p2p)
if (ETHASHCL)

1
libethereum/BlockChain.cpp

@ -137,7 +137,6 @@ BlockChain::BlockChain(bytes const& _genesisBlock, std::unordered_map<Address, A
// Initialise with the genesis as the last block on the longest chain.
m_genesisBlock = _genesisBlock;
m_genesisHash = sha3(RLP(m_genesisBlock)[0].data());
m_genesisState = _genesisState;
// remove the next line real soon. we don't need to be supporting this forever.
upgradeDatabase(_path, genesisHash());

3
libtestutils/BlockChainLoader.cpp

@ -19,6 +19,7 @@
* @date 2015
*/
#include <libethereum/CanonBlockChain.h>
#include "BlockChainLoader.h"
#include "StateLoader.h"
#include "Common.h"
@ -35,7 +36,7 @@ BlockChainLoader::BlockChainLoader(Json::Value const& _json)
m_state = sl.state();
// load genesisBlock
m_bc.reset(new BlockChain(fromHex(_json["genesisRLP"].asString()), m_dir.path(), WithExisting::Kill));
m_bc.reset(new FullBlockChain<Ethash>(fromHex(_json["genesisRLP"].asString()), sl.stateDefinition(), m_dir.path(), WithExisting::Kill));
assert(m_state.rootHash() == m_bc->info().stateRoot());
// load blocks

2
libtestutils/StateLoader.cpp

@ -27,7 +27,7 @@ using namespace dev::eth;
using namespace dev::test;
StateLoader::StateLoader(Json::Value const& _json, std::string const& _dbPath):
m_state(State::openDB(_dbPath, WithExisting::Kill), BaseState::Empty)
m_state(State::openDB(_dbPath, h256{}, WithExisting::Kill), BaseState::Empty)
{
for (string const& name: _json.getMemberNames())
{

2
libtestutils/StateLoader.h

@ -24,6 +24,7 @@
#include <json/json.h>
#include <libdevcore/TransientDirectory.h>
#include <libethereum/State.h>
#include <libethereum/BlockChain.h>
namespace dev
{
@ -38,6 +39,7 @@ class StateLoader
public:
StateLoader(Json::Value const& _json, std::string const& _dbPath);
eth::State const& state() const { return m_state; }
eth::StateDefinition const& stateDefinition() const { return m_state.m_cache; }
private:
eth::State m_state;

8
libweb3jsonrpc/JsonHelper.cpp

@ -93,10 +93,10 @@ Json::Value toJson(dev::eth::BlockInfo const& _bi)
res["miner"] = toJS(_bi.coinbaseAddress());
res["stateRoot"] = toJS(_bi.stateRoot());
res["transactionsRoot"] = toJS(_bi.transactionsRoot());
res["difficulty"] = toJS(_bi.difficulty);
res["difficulty"] = toJS(_bi.difficulty());
res["number"] = toJS(_bi.number());
res["gasUsed"] = toJS(_bi.gasUsed);
res["gasLimit"] = toJS(_bi.gasLimit);
res["gasUsed"] = toJS(_bi.gasUsed());
res["gasLimit"] = toJS(_bi.gasLimit());
res["timestamp"] = toJS(_bi.timestamp());
res["extraData"] = toJS(_bi.extraData());
res["logsBloom"] = toJS(_bi.logBloom());
@ -176,7 +176,7 @@ Json::Value toJson(dev::eth::TransactionSkeleton const& _t)
Json::Value toJson(dev::eth::TransactionReceipt const& _t)
{
Json::Value res;
res["stateRoot"] = toJS(_t.stateRoot()());
res["stateRoot"] = toJS(_t.stateRoot());
res["gasUsed"] = toJS(_t.gasUsed());
res["bloom"] = toJS(_t.bloom());
res["log"] = dev::toJson(_t.log());

2
libweb3jsonrpc/WebThreeStubServer.cpp

@ -106,7 +106,7 @@ bool WebThreeStubServer::admin_eth_setBidPrice(std::string const& _wei, std::str
return true;
}
dev::eth::CanonBlockChain const& WebThreeStubServer::bc() const
dev::eth::BlockChain const& WebThreeStubServer::bc() const
{
return m_web3.ethereum()->blockChain();
}

4
libweb3jsonrpc/WebThreeStubServer.h

@ -34,7 +34,7 @@ namespace eth
{
class KeyManager;
class TrivialGasPricer;
class CanonBlockChain;
class BlockChain;
class BlockQueue;
}
@ -89,7 +89,7 @@ private:
private:
h256 blockHash(std::string const& _blockNumberOrHash) const;
dev::eth::CanonBlockChain const& bc() const;
dev::eth::BlockChain const& bc() const;
dev::eth::BlockQueue const& bq() const;
dev::WebThreeDirect& m_web3;

2
libwebthree/WebThree.cpp

@ -52,7 +52,7 @@ WebThreeDirect::WebThreeDirect(
Defaults::setDBPath(_dbPath);
if (_interfaces.count("eth"))
{
m_ethereum.reset(new eth::Client(&m_net, _dbPath, _we, 0));
m_ethereum.reset(new eth::EthashClient(&m_net, shared_ptr<GasPricer>(), _dbPath, _we, 0));
m_ethereum->setExtraData(rlpList(0, _clientVersion, m_net.id()));
}

4
mix/ClientModel.cpp

@ -686,9 +686,9 @@ RecordLogEntry* ClientModel::lastBlock() const
{
eth::BlockInfo blockInfo = m_client->blockInfo();
stringstream strGas;
strGas << blockInfo.gasUsed;
strGas << blockInfo.gasUsed();
stringstream strNumber;
strNumber << blockInfo.number;
strNumber << blockInfo.number();
RecordLogEntry* record = new RecordLogEntry(0, QString::fromStdString(strNumber.str()), tr(" - Block - "), tr("Hash: ") + QString(QString::fromStdString(dev::toHex(blockInfo.hash().ref()))), QString(), QString(), QString(), false, RecordLogEntry::RecordType::Block, QString::fromStdString(strGas.str()), QString(), tr("Block"), QVariantMap(), QVariantMap(), QVariantList());
QQmlEngine::setObjectOwnership(record, QQmlEngine::JavaScriptOwnership);
return record;

36
mix/MixClient.cpp

@ -24,12 +24,13 @@
#include <vector>
#include <utility>
#include <libdevcore/Exceptions.h>
#include <libethcore/Params.h>
#include <libethcore/BasicAuthority.h>
#include <libethereum/CanonBlockChain.h>
#include <libethereum/Transaction.h>
#include <libethereum/Executive.h>
#include <libethereum/ExtVM.h>
#include <libethereum/BlockChain.h>
#include <libethcore/Params.h>
#include <libevm/VM.h>
#include "Exceptions.h"
using namespace std;
@ -45,22 +46,20 @@ u256 const c_mixGenesisDifficulty = 131072; //TODO: make it lower for Mix someho
namespace
{
}
struct MixPow //dummy POW
MixBlockChain::MixBlockChain(std::string const& _path, h256 _stateRoot):
FullBlockChain<NoProof>(createGenesisBlock(_stateRoot), std::unordered_map<Address, Account>(), _path, WithExisting::Kill)
{
typedef int Solution;
static bool verify(BlockInfo const&) { return true; }
};
}
bytes MixBlockChain::createGenesisBlock(h256 _stateRoot)
{
RLPStream block(3);
block.appendList(15)
block.appendList(13)
<< h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie
<< LogBloom() << c_mixGenesisDifficulty << 0 << c_genesisGasLimit << 0 << (unsigned)0
<< std::string() << h256() << h64(u64(42));
<< std::string();
block.appendRaw(RLPEmptyList);
block.appendRaw(RLPEmptyList);
return block.out();
@ -78,7 +77,6 @@ MixClient::~MixClient()
void MixClient::resetState(std::unordered_map<Address, Account> const& _accounts, Secret const& _miner)
{
WriteGuard l(x_state);
Guard fl(x_filtersWatches);
@ -91,12 +89,13 @@ void MixClient::resetState(std::unordered_map<Address, Account> const& _accounts
SecureTrieDB<Address, MemoryDB> accountState(&m_stateDB);
accountState.init();
dev::eth::commit(_accounts, static_cast<MemoryDB&>(m_stateDB), accountState);
dev::eth::commit(_accounts, accountState);
h256 stateRoot = accountState.root();
m_bc.reset();
m_bc.reset(new MixBlockChain(m_dbPath, stateRoot));
m_state = eth::State(m_stateDB, BaseState::PreExisting, KeyPair(_miner).address());
m_state.sync(bc());
State s(m_stateDB, BaseState::PreExisting, KeyPair(_miner).address());
s.sync(bc());
m_state = s;
m_startState = m_state;
WriteGuard lx(x_executions);
m_executions.clear();
@ -275,11 +274,14 @@ void MixClient::mine()
{
WriteGuard l(x_state);
m_state.commitToMine(bc());
m_state.completeMine<MixPow>(0);
bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Default & ~ImportRequirements::ValidNonce);
NoProof::BlockHeader h(m_state.info());
RLPStream header;
h.streamRLP(header);
m_state.sealBlock(header.out());
bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Default & ~ImportRequirements::ValidSeal);
m_state.sync(bc());
m_startState = m_state;
h256Set changed { dev::eth::PendingChangedFilter, dev::eth::ChainChangedFilter };
}
ExecutionResult MixClient::lastExecution() const
@ -383,9 +385,9 @@ uint64_t MixClient::hashrate() const
return 0;
}
eth::MiningProgress MixClient::miningProgress() const
eth::WorkingProgress MixClient::miningProgress() const
{
return eth::MiningProgress();
return eth::WorkingProgress();
}
}

36
mix/MixClient.h

@ -25,6 +25,7 @@
#include <vector>
#include <string>
#include <libethcore/BasicAuthority.h>
#include <libethereum/ExtVM.h>
#include <libethereum/ClientBase.h>
#include <libethereum/Client.h>
@ -32,13 +33,40 @@
namespace dev
{
namespace mix
{
class MixBlockChain: public dev::eth::BlockChain
class NoProof
{
class BlockHeaderRaw: public dev::eth::BlockInfo
{
public:
static const unsigned SealFields = 0;
protected:
BlockHeaderRaw() = default;
BlockHeaderRaw(BlockInfo const& _bi): BlockInfo(_bi) {}
void populateFromHeader(RLP const& _header, dev::eth::Strictness _s) { (void) _header; (void) _s; }
void populateFromParent(BlockHeaderRaw const& _parent) { (void)_parent; }
void streamRLPFields(RLPStream& _s) const { (void) _s; }
};
public:
static std::string name() { return "NoProof"; }
static unsigned revision() { return 0; }
using BlockHeader = dev::eth::BlockHeaderPolished<BlockHeaderRaw>;
private:
static AddressHash s_authorities;
};
class MixBlockChain: public dev::eth::FullBlockChain<NoProof>
{
public:
MixBlockChain(std::string const& _path, h256 _stateRoot): BlockChain(createGenesisBlock(_stateRoot), _path, WithExisting::Kill) {}
MixBlockChain(std::string const& _path, h256 _stateRoot);
static bytes createGenesisBlock(h256 _stateRoot);
};
@ -67,9 +95,7 @@ public:
void stopMining() override;
bool isMining() const override;
uint64_t hashrate() const override;
eth::MiningProgress miningProgress() const override;
eth::ProofOfWork::WorkPackage getWork() override { return eth::ProofOfWork::WorkPackage(); }
bool submitWork(eth::ProofOfWork::Solution const&) override { return false; }
eth::WorkingProgress miningProgress() const override;
virtual void flushTransactions() override {}
/// @returns the last mined block information

Loading…
Cancel
Save