From 631e701fdf0b7ebdb5b50083625c54364b4e075e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 20 Jul 2015 19:18:51 +0200 Subject: [PATCH] Fix dejavu week 1, issue 1. Reenable bits of ethash. --- libdevcore/CommonIO.cpp | 2 ++ libethereum/BlockChain.cpp | 6 ++---- libethereum/Client.h | 1 + libweb3jsonrpc/WebThreeStubServerBase.cpp | 18 +++++------------- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 055b645ed..067d75559 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -111,11 +111,13 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDe // create directory if not existent fs::path p(_file); fs::create_directories(p.parent_path()); + fs::permissions(p.parent_path(), fs::owner_all); ofstream s(_file, ios::trunc | ios::binary); s.write(reinterpret_cast(_data.data()), _data.size()); if (!s) BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file)); + fs::permissions(_file, fs::owner_read|fs::owner_write); } } diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 5dfd66cee..61c3ecf0c 100644 --- a/libethereum/BlockChain.cpp +++ b/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; -#if ETH_USING_ETHASH StructuredLogger::chainNewHead( - _block.info.headerHash(WithoutProof).abridged(), - _block.info.proof.nonce.abridged(), + _block.info.hashWithout().abridged(), + "",//_block.info.proof.nonce.abridged(), currentHash().abridged(), _block.info.parentHash().abridged() ); -#endif } else { diff --git a/libethereum/Client.h b/libethereum/Client.h index 896444176..8ea28ec1e 100644 --- a/libethereum/Client.h +++ b/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 /// nonce (the 'work hash') and the difficulty to be met. + /// @returns Tuple of target boundary, hash without seal, seed hash. virtual std::tuple getEthashWork() override; /** @brief Submit the proof for the proof-of-work. diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index df2006cc5..4363b2466 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -748,12 +748,10 @@ Json::Value WebThreeStubServerBase::eth_getLogsEx(Json::Value const& _json) Json::Value WebThreeStubServerBase::eth_getWork() { Json::Value ret(Json::arrayValue); -#if ETH_USING_ETHASH - auto r = client()->getWork(); - ret.append(toJS(r.headerHash)); - ret.append(toJS(r.seedHash)); - ret.append(toJS(r.boundary)); -#endif + auto r = client()->getEthashWork(); + ret.append(toJS(get<0>(r))); + ret.append(toJS(get<1>(r))); + ret.append(toJS(get<2>(r))); return ret; } @@ -761,13 +759,7 @@ bool WebThreeStubServerBase::eth_submitWork(string const& _nonce, string const&, { try { -#if ETH_USING_ETHASH - return client()->submitWork(Ethash::Solution{jsToFixed(_nonce), jsToFixed<32>(_mixHash)}); -#else - (void)_nonce; - (void)_mixHash; - return false; -#endif + return client()->submitEthashWork(jsToFixed<32>(_mixHash), jsToFixed(_nonce)); } catch (...) {