Browse Source

Fix dejavu week 1, issue 1.

Reenable bits of ethash.
cl-refactor
Gav Wood 10 years ago
parent
commit
631e701fdf
  1. 2
      libdevcore/CommonIO.cpp
  2. 6
      libethereum/BlockChain.cpp
  3. 1
      libethereum/Client.h
  4. 18
      libweb3jsonrpc/WebThreeStubServerBase.cpp

2
libdevcore/CommonIO.cpp

@ -111,11 +111,13 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDe
// create directory if not existent // create directory if not existent
fs::path p(_file); fs::path p(_file);
fs::create_directories(p.parent_path()); fs::create_directories(p.parent_path());
fs::permissions(p.parent_path(), fs::owner_all);
ofstream s(_file, ios::trunc | ios::binary); ofstream s(_file, ios::trunc | ios::binary);
s.write(reinterpret_cast<char const*>(_data.data()), _data.size()); s.write(reinterpret_cast<char const*>(_data.data()), _data.size());
if (!s) if (!s)
BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file)); BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file));
fs::permissions(_file, fs::owner_read|fs::owner_write);
} }
} }

6
libethereum/BlockChain.cpp

@ -669,14 +669,12 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const&
clog(BlockChainNote) << " Imported and best" << td << " (#" << _block.info.number() << "). Has" << (details(_block.info.parentHash()).children.size() - 1) << "siblings. Route:" << route; clog(BlockChainNote) << " Imported and best" << td << " (#" << _block.info.number() << "). Has" << (details(_block.info.parentHash()).children.size() - 1) << "siblings. Route:" << route;
#if ETH_USING_ETHASH
StructuredLogger::chainNewHead( StructuredLogger::chainNewHead(
_block.info.headerHash(WithoutProof).abridged(), _block.info.hashWithout().abridged(),
_block.info.proof.nonce.abridged(), "",//_block.info.proof.nonce.abridged(),
currentHash().abridged(), currentHash().abridged(),
_block.info.parentHash().abridged() _block.info.parentHash().abridged()
); );
#endif
} }
else else
{ {

1
libethereum/Client.h

@ -380,6 +380,7 @@ public:
/// Update to the latest transactions and get hash of the current block to be mined minus the /// Update to the latest transactions and get hash of the current block to be mined minus the
/// nonce (the 'work hash') and the difficulty to be met. /// nonce (the 'work hash') and the difficulty to be met.
/// @returns Tuple of target boundary, hash without seal, seed hash.
virtual std::tuple<h256, h256, h256> getEthashWork() override; virtual std::tuple<h256, h256, h256> getEthashWork() override;
/** @brief Submit the proof for the proof-of-work. /** @brief Submit the proof for the proof-of-work.

18
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -748,12 +748,10 @@ Json::Value WebThreeStubServerBase::eth_getLogsEx(Json::Value const& _json)
Json::Value WebThreeStubServerBase::eth_getWork() Json::Value WebThreeStubServerBase::eth_getWork()
{ {
Json::Value ret(Json::arrayValue); Json::Value ret(Json::arrayValue);
#if ETH_USING_ETHASH auto r = client()->getEthashWork();
auto r = client()->getWork(); ret.append(toJS(get<0>(r)));
ret.append(toJS(r.headerHash)); ret.append(toJS(get<1>(r)));
ret.append(toJS(r.seedHash)); ret.append(toJS(get<2>(r)));
ret.append(toJS(r.boundary));
#endif
return ret; return ret;
} }
@ -761,13 +759,7 @@ bool WebThreeStubServerBase::eth_submitWork(string const& _nonce, string const&,
{ {
try try
{ {
#if ETH_USING_ETHASH return client()->submitEthashWork(jsToFixed<32>(_mixHash), jsToFixed<Nonce::size>(_nonce));
return client()->submitWork(Ethash::Solution{jsToFixed<Nonce::size>(_nonce), jsToFixed<32>(_mixHash)});
#else
(void)_nonce;
(void)_mixHash;
return false;
#endif
} }
catch (...) catch (...)
{ {

Loading…
Cancel
Save