Skip to content

Commit

Permalink
fix consensus to allow one consensus block per peer per index
Browse files Browse the repository at this point in the history
  • Loading branch information
pdxwebdev committed Dec 15, 2020
1 parent dfda96f commit 692223b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions yadacoin/core/consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ async def insert_consensus_block(self, block, peer):
block.verify()
except:
return
await self.mongo.async_db.consensus.replace_one({
'id': block.signature,
await self.mongo.async_db.consensus.delete_many({
'index': block.index,
'peer.rid': peer.rid
},
{
})
await self.mongo.async_db.consensus.update_one({
'block': block.to_dict(),
'index': block.index,
'id': block.signature,
'peer': peer.to_dict()
}, upsert=True)
})

async def sync_bottom_up(self):
#bottom up syncing
Expand Down
1 change: 1 addition & 0 deletions yadacoin/tcpsocket/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ async def authenticate(self, body, stream):
if result:
stream.peer.authenticated = True
self.config.app_log.info('Authenticated {}: {}'.format(stream.peer.__class__.__name__, stream.peer.to_json()))
await self.send_block(self.config.LatestBlock.block)
else:
stream.close()

Expand Down

0 comments on commit 692223b

Please sign in to comment.