diff --git a/libethereum/BlockQueue.cpp b/libethereum/BlockQueue.cpp index d98dac3ba..70ea8753b 100644 --- a/libethereum/BlockQueue.cpp +++ b/libethereum/BlockQueue.cpp @@ -70,7 +70,8 @@ ImportResult BlockQueue::import(bytesConstRef _block, BlockChain const& _bc, boo UpgradeGuard ul(l); // Check it's not in the future - if (bi.timestamp > (u256)time(0) && !_isOurs) + (void)_isOurs; + if (bi.timestamp > (u256)time(0)/* && !_isOurs*/) { m_future.insert(make_pair((unsigned)bi.timestamp, _block.toBytes())); cblockq << "OK - queued for future."; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 9e69c8128..b9df1cf90 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -585,11 +585,21 @@ void Client::doWork() if (m_syncBlockQueue.compare_exchange_strong(t, false)) syncBlockQueue(); - checkWatchGarbage(); + tick(); this_thread::sleep_for(chrono::milliseconds(20)); } +void Client::tick() +{ + if (chrono::system_clock::now() - m_lastTick > chrono::seconds(1)) + { + checkWatchGarbage(); + m_bq.tick(m_bc); + m_lastTick = chrono::system_clock::now(); + } +} + void Client::checkWatchGarbage() { if (chrono::system_clock::now() - m_lastGarbageCollection > chrono::seconds(5)) diff --git a/libethereum/Client.h b/libethereum/Client.h index dedb3bcf1..1dfa45d7e 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -260,8 +260,12 @@ private: /// This updates m_miningInfo. void onPostStateChanged(); + /// Does garbage collection on watches. void checkWatchGarbage(); + /// Ticks various system-level objects. + void tick(); + VersionChecker m_vc; ///< Dummy object to check & update the protocol version. CanonBlockChain m_bc; ///< Maintains block database. BlockQueue m_bq; ///< Maintains a list of incoming blocks not yet on the blockchain (to be imported). @@ -286,6 +290,8 @@ private: mutable std::chrono::system_clock::time_point m_lastGarbageCollection; ///< When did we last both doing GC on the watches? + mutable std::chrono::system_clock::time_point m_lastTick = std::chrono::system_clock::now(); + ///< When did we last tick()? // TODO!!!!!! REPLACE WITH A PROPER X-THREAD ASIO SIGNAL SYSTEM (could just be condition variables) std::atomic m_syncTransactionQueue = {false};