From 5e06a78f18c92f261df79ddc56ca5711f9b17747 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Thu, 22 Nov 2018 17:21:18 +0100 Subject: [PATCH] Return from test::mine after Client updates its pending block --- libethereum/Client.cpp | 1 - libethereum/Client.h | 7 ------- test/tools/libtesteth/TestHelper.cpp | 7 ++++--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 828a446777f..42897133195 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -122,7 +122,6 @@ void Client::init(p2p::Host& _extNet, fs::path const& _dbPath, bc().setOnBlockImport([=](BlockHeader const& _info) { if (auto h = m_host.lock()) h->onBlockImported(_info); - m_onBlockImport(_info); }); if (_forceAction == WithExisting::Rescue) diff --git a/libethereum/Client.h b/libethereum/Client.h index be7e14328b5..966d34892de 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -216,11 +216,6 @@ class Client: public ClientBase, protected Worker /// should be called after the constructor of the most derived class finishes. void startWorking() { Worker::startWorking(); }; - /// Change the function that is called when a new block is imported - Handler setOnBlockImport(std::function _handler) - { - return m_onBlockImport.add(_handler); - } /// Change the function that is called when a new block is sealed Handler setOnBlockSealed(std::function _handler) { @@ -375,8 +370,6 @@ class Client: public ClientBase, protected Worker bytes m_extraData; - Signal m_onBlockImport; ///< Called if we have imported a new block into - ///< the DB Signal m_onBlockSealed; ///< Called if we have sealed a new block /// Called when blockchain was changed diff --git a/test/tools/libtesteth/TestHelper.cpp b/test/tools/libtesteth/TestHelper.cpp index 18774a530dd..ea367a85bb8 100644 --- a/test/tools/libtesteth/TestHelper.cpp +++ b/test/tools/libtesteth/TestHelper.cpp @@ -53,9 +53,10 @@ void mine(Client& _c, int _numBlocks) int importedBlocks = 0; std::promise allBlocksImported; - auto importHandler = - _c.setOnBlockImport([_numBlocks, &importedBlocks, &allBlocksImported](BlockHeader const&) { - if (++importedBlocks == _numBlocks) + auto chainChangedHandler = _c.setOnChainChanged( + [_numBlocks, &importedBlocks, &allBlocksImported](h256s const&, h256s const& _newBlocks) { + importedBlocks += _newBlocks.size(); + if (importedBlocks == _numBlocks) allBlocksImported.set_value(); });