From df6898538fcc2e8209a1fdd9cb2da2bf7659d911 Mon Sep 17 00:00:00 2001 From: arkpar Date: Mon, 20 Jul 2015 08:58:44 +0200 Subject: [PATCH] restored toSlice code for c++11, fixed build --- CMakeLists.txt | 6 ++---- libethereum/BlockChain.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e686422..0d92ee90a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -405,10 +405,8 @@ if (JSCONSOLE) add_subdirectory(ethconsole) endif () -if (NOT WIN32) - add_definitions(-DETH_HAVE_SECP256K1) - add_subdirectory(secp256k1) -endif () +add_definitions(-DETH_HAVE_SECP256K1) +add_subdirectory(secp256k1) add_subdirectory(libscrypt) add_subdirectory(libdevcrypto) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 00117e679..99e52d92e 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -84,22 +84,35 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) ldb::Slice dev::eth::toSlice(h256 const& _h, unsigned _sub) { +#if TRUE //ALL_COMPILERS_ARE_CPP11_COMPLIANT + static thread_local FixedHash<33> h = _h; + h[32] = (uint8_t)_sub; + return (ldb::Slice)h.ref(); +#else static boost::thread_specific_ptr> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); *t_h = FixedHash<33>(_h); (*t_h)[32] = (uint8_t)_sub; - return (ldb::Slice)t_h->ref();//(char const*)t_h.get(), 32); + return (ldb::Slice)t_h->ref(); +#endif //ALL_COMPILERS_ARE_CPP11_COMPLIANT } ldb::Slice dev::eth::toSlice(uint64_t _n, unsigned _sub) { +#if TRUE //ALL_COMPILERS_ARE_CPP11_COMPLIANT + static thread_local FixedHash<33> h; + toBigEndian(_n, bytesRef(h.data() + 24, 8)); + h[32] = (uint8_t)_sub; + return (ldb::Slice)h.ref(); +#else static boost::thread_specific_ptr> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); toBigEndian(_n, bytesRef(t_h->data() + 24, 8)); (*t_h)[32] = (uint8_t)_sub; return (ldb::Slice)t_h->ref(); +#endif } namespace dev @@ -613,7 +626,7 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const& unsigned n = number(route.front()); DEV_WRITE_GUARDED(x_blockHashes) for (auto i = route.begin(); i != route.end() && *i != common; ++i, --n) - m_blockHashes.erase(h256(u256(n))); + m_blockHashes.erase(n); DEV_WRITE_GUARDED(x_transactionAddresses) m_transactionAddresses.clear(); // TODO: could perhaps delete them individually?