Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Return from test::mine after Client updates its pending block
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Nov 22, 2018
1 parent e969634 commit 5e06a78
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
1 change: 0 additions & 1 deletion libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions libethereum/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockHeader const&> setOnBlockImport(std::function<void(BlockHeader const&)> _handler)
{
return m_onBlockImport.add(_handler);
}
/// Change the function that is called when a new block is sealed
Handler<bytes const&> setOnBlockSealed(std::function<void(bytes const&)> _handler)
{
Expand Down Expand Up @@ -375,8 +370,6 @@ class Client: public ClientBase, protected Worker

bytes m_extraData;

Signal<BlockHeader const&> m_onBlockImport; ///< Called if we have imported a new block into
///< the DB
Signal<bytes const&> m_onBlockSealed; ///< Called if we have sealed a new block

/// Called when blockchain was changed
Expand Down
7 changes: 4 additions & 3 deletions test/tools/libtesteth/TestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ void mine(Client& _c, int _numBlocks)

int importedBlocks = 0;
std::promise<void> 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();
});

Expand Down

0 comments on commit 5e06a78

Please sign in to comment.