Skip to content
Snippets Groups Projects
Commit e768deac authored by inso's avatar inso
Browse files

Squashed commit of the following:

commit fdb977d1
Author: inso <insomniak.fr@gmaiL.com>
Date:   Mon Mar 12 16:01:59 2018 +0100

    Add connector if we go below the limit

commit 36c80d9f
Author: inso <insomniak.fr@gmaiL.com>
Date:   Mon Mar 12 15:57:42 2018 +0100

    Stabilisation of WS2P requests

commit f782e818
Author: inso <insomniak.fr@gmaiL.com>
Date:   Mon Mar 12 14:09:55 2018 +0100

    Use WS2P to detect consensus
parent fdb977d1
No related branches found
No related tags found
No related merge requests found
......@@ -165,7 +165,15 @@ class BmaConnector:
async def _verified_request(self, node, request):
try:
return await request
res = await request
self._nodes_processor.handle_success(node)
return res
except errors.DuniterError as e:
if e.ucode == errors.HTTP_LIMITATION:
self._logger.debug("Exception in responses : " + str(e))
self._nodes_processor.handle_failure(node)
else:
return e
except BaseException as e:
self._logger.debug(str(e))
self._nodes_processor.handle_failure(node)
......@@ -233,6 +241,7 @@ class BmaConnector:
else:
return _best_answer(answers, answers_data, nb_verification)
nodes = self._nodes_processor.nodes(currency)
raise NoPeerAvailable("", len(synced_nodes))
async def simple_get(self, currency, request, req_args):
......
......@@ -87,7 +87,7 @@ class NetworkService(QObject):
sample.append(n)
continue
for node in random.sample(sample, 6):
for node in random.sample(sample, min(len(sample), 6)):
connectors.append(NodeConnector(node, app.parameters))
network = cls(app, currency, node_processor, connectors, blockchain_service, identities_service)
return network
......@@ -176,7 +176,7 @@ class NetworkService(QObject):
sample.append(n)
continue
for node in random.sample(sample, 1):
for node in random.sample(sample, min(len(sample), 1)):
self.add_connector(NodeConnector(node, self.app.parameters))
......
......@@ -102,7 +102,7 @@ def fake_server(application, event_loop):
uid="",
current_buid=BlockUID.empty(),
current_ts=0,
state=Node.ONLINE,
state=0,
software="duniter",
version="0.40.2"))
application.instanciate_services()
......
......@@ -65,7 +65,7 @@ async def test_register_empty_blockchain(application, fake_server, bob, tmpdir):
assert len(ConnectionsProcessor.instanciate(application).connections()) == 1
accept_dialog("Registration")
application.loop.call_later(10, close_dialog)
application.loop.call_later(30, close_dialog)
asyncio.ensure_future(exec_test())
await connection_config_dialog.async_exec()
await fake_server.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment