Try to fix server

This commit is contained in:
Mariano Sorgente 2020-02-07 01:08:17 -05:00
parent e7eec45e85
commit 40c751ba72
No known key found for this signature in database
GPG Key ID: 0F866338C369278C
2 changed files with 6 additions and 4 deletions

View File

@ -206,24 +206,26 @@ public:
: acceptor_(io_service, tcp::endpoint(tcp::v4(), port)),
socket_(io_service)
{
io_service_ = &io_service;
do_accept();
}
private:
void do_accept()
{
acceptor_.async_accept(socket_,
this->socket_ = tcp::socket(*io_service_);
acceptor_.async_accept(this->socket_,
[this](boost::system::error_code ec)
{
if (!ec)
{
std::make_shared<session>(std::move(socket_))->start();
std::make_shared<session>(std::move(this->socket_))->start();
}
do_accept();
});
}
boost::asio::io_service* io_service_;
tcp::acceptor acceptor_;
tcp::socket socket_;
};

View File

@ -22,7 +22,7 @@ class TestSimulation:
start = time.time()
while time.time() - start < 100:
if max([h.height for h in node1.blockchain.get_current_tips()]) > 10:
return
break
await asyncio.sleep(1)
tip_heights = [t.height for t in node1.blockchain.get_current_tips()]
assert max(tip_heights) > 5