Skip to content

Commit

Permalink
fix disconnect repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
pdxwebdev committed Apr 12, 2022
1 parent a315db6 commit 25bfc5e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
18 changes: 14 additions & 4 deletions yadacoin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ async def background_message_sender(self):
if x not in retry_attempts:
retry_attempts[x] = 0
retry_attempts[x] += 1
for peer_cls in self.config.nodeServer.inbound_streams.keys():
for peer_cls in list(self.config.nodeServer.inbound_streams.keys()):
if x[0] in self.config.nodeServer.inbound_streams[peer_cls]:
if retry_attempts[x] > 10:
del self.config.nodeServer.retry_messages[x]
for y in list(self.config.nodeServer.retry_messages):
if y[0] == x[0]:
del self.config.nodeServer.retry_messages[y]
for y in list(retry_attempts):
if y[0] == x[0]:
del retry_attempts[y]
await self.remove_peer(self.config.nodeServer.inbound_streams[peer_cls][x[0]])
continue
if len(x) > 3:
Expand All @@ -221,10 +226,15 @@ async def background_message_sender(self):
if x not in retry_attempts:
retry_attempts[x] = 0
retry_attempts[x] += 1
for peer_cls in self.config.nodeClient.outbound_streams.keys():
for peer_cls in list(self.config.nodeClient.outbound_streams.keys()):
if x[0] in self.config.nodeClient.outbound_streams[peer_cls]:
if retry_attempts[x] > 10:
del self.config.nodeClient.retry_messages[x]
for y in self.config.nodeServer.retry_messages:
if y[0] == x[0]:
del self.config.nodeServer.retry_messages[y]
for y in retry_attempts:
if y[0] == x[0]:
del retry_attempts[y]
await self.remove_peer(self.config.nodeClient.outbound_streams[peer_cls][x[0]])
continue
if len(x) > 3:
Expand Down
16 changes: 8 additions & 8 deletions yadacoin/tcpsocket/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ async def newtxn(self, body, stream):
):
return

if stream.peer.protocol_version > 2:
await self.write_result(
stream,
'newtxn_confirmed',
body.get('params', {}),
body['id']
)

txn = Transaction.from_dict(payload.get('transaction'))
try:
await txn.verify()
Expand All @@ -126,14 +134,6 @@ async def newtxn(self, body, stream):
upsert=True
)

if stream.peer.protocol_version > 2:
await self.write_result(
stream,
'newtxn_confirmed',
body.get('params', {}),
body['id']
)

async for peer_stream in self.config.peer.get_sync_peers():
if peer_stream.peer.rid == stream.peer.rid:
continue
Expand Down

0 comments on commit 25bfc5e

Please sign in to comment.