diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 0baff8057..4e5386412 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -386,6 +386,7 @@ tuple BlockChain::sync(BlockQueue& _bq, OverlayDB c if (!badBlocks.empty()) badBlocks.push_back(block.verified.info.hash()); else + { do { try { @@ -427,6 +428,7 @@ tuple BlockChain::sync(BlockQueue& _bq, OverlayDB c badBlocks.push_back(block.verified.info.hash()); } } while (false); + } return make_tuple(ImportRoute{dead, fresh, goodTransactions}, _bq.doneDrain(badBlocks), count); } diff --git a/libp2p/Common.h b/libp2p/Common.h index 4c7fa837b..1b65d4759 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -243,25 +243,7 @@ public: void stop() { m_stopped = true; DEV_GUARDED(x_timers) m_timers.clear(); } protected: - void reap() - { - Guard l(x_timers); - std::vector::iterator t = m_timers.begin(); - while (t != m_timers.end()) - if (t->expired()) - { - t->wait(); - t = m_timers.erase(t); - } - else - t++; - - m_timers.emplace_back(m_io, m_reapIntervalMs, [this](boost::system::error_code const& ec) - { - if (!ec) - reap(); - }); - } + void reap(); private: ba::io_service& m_io; diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index 4e8f7cf92..84e9b1a31 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -158,17 +158,13 @@ void WhisperMessagesDB::saveSingleMessage(h256 const& _key, Envelope const& _e) } } -vector WhisperFiltersDB::restoreTopicsFromDB(WhisperHost* _host, string const& _password) +vector WhisperFiltersDB::restoreTopicsFromDB(WhisperHost* _host, h256 const& _id) { vector ret; - h256 s = sha3(_password); - h256 h = sha3(s); - string raw = lookup(h); + string raw = lookup(_id); if (!raw.empty()) { - bytes plain; - decryptSym(s, raw, plain); - RLP rlp(plain); + RLP rlp(raw); auto sz = rlp.itemCountStrict(); for (unsigned i = 0; i < sz; ++i) @@ -191,15 +187,11 @@ vector WhisperFiltersDB::restoreTopicsFromDB(WhisperHost* _host, strin return ret; } -void WhisperFiltersDB::saveTopicsToDB(WhisperHost const& _host, std::string const& _password) +void WhisperFiltersDB::saveTopicsToDB(WhisperHost const& _host, h256 const& _id) { - bytes plain; + bytes b; RLPStream rlp; _host.exportFilters(rlp); - rlp.swapOut(plain); - h256 s = sha3(_password); - h256 h = sha3(s); - bytes encrypted; - encryptSym(s, &plain, encrypted); - insert(h, encrypted); + rlp.swapOut(b); + insert(_id, b); } diff --git a/libwhisper/WhisperDB.h b/libwhisper/WhisperDB.h index 6ca79666f..bd6a22251 100644 --- a/libwhisper/WhisperDB.h +++ b/libwhisper/WhisperDB.h @@ -69,8 +69,8 @@ class WhisperFiltersDB: public WhisperDB public: WhisperFiltersDB(): WhisperDB("filters") {} virtual ~WhisperFiltersDB() {} - std::vector restoreTopicsFromDB(WhisperHost* _host, std::string const& _password); - void saveTopicsToDB(WhisperHost const& _host, std::string const& _password); + std::vector restoreTopicsFromDB(WhisperHost* _host, h256 const& _id); + void saveTopicsToDB(WhisperHost const& _host, h256 const& _id); }; } diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index aca6f6914..38486772d 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(filters) { cnote << "Testing filters saving..."; VerbosityHolder setTemporaryLevel(2); - string const password("some pseudorandom string"); + h256 persistID(0xC0FFEE); { WhisperFiltersDB db; @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(filters) auto wh = h.registerCapability(new WhisperHost()); wh->installWatch(BuildTopic("t1")); wh->installWatch(BuildTopic("t2")); - db.saveTopicsToDB(*wh, password); + db.saveTopicsToDB(*wh, persistID); } short unsigned port1 = 30313; @@ -236,8 +236,8 @@ BOOST_AUTO_TEST_CASE(filters) auto whost1 = host1.registerCapability(new WhisperHost()); host1.start(); WhisperFiltersDB db; - auto watches = db.restoreTopicsFromDB(whost1.get(), password); - auto zero = db.restoreTopicsFromDB(whost1.get(), password + "qwer"); + auto watches = db.restoreTopicsFromDB(whost1.get(), persistID); + auto zero = db.restoreTopicsFromDB(whost1.get(), ++persistID); BOOST_REQUIRE(!watches.empty()); BOOST_REQUIRE(zero.empty());