forked from LBRYCommunity/lbry-sdk
check membership instead of one update per peer
This commit is contained in:
parent
443a1c32fa
commit
be4c62cf32
1 changed files with 3 additions and 3 deletions
|
@ -148,9 +148,9 @@ class Crawler:
|
||||||
to_peer_id=self.get_from_peer(peer).peer_id)
|
to_peer_id=self.get_from_peer(peer).peer_id)
|
||||||
for peer in peers
|
for peer in peers
|
||||||
}
|
}
|
||||||
for peer in peers:
|
all_peer_ids = {peer.node_id for peer in peers if peer.node_id}
|
||||||
self.db.query(DHTPeer).filter(DHTPeer.address == peer.address, DHTPeer.udp_port == peer.udp_port).update(
|
print(self.db.query(DHTPeer).filter(DHTPeer.node_id.in_(all_peer_ids)).update(
|
||||||
{DHTPeer.last_seen: datetime.datetime.utcnow()})
|
{DHTPeer.last_seen: datetime.datetime.utcnow()}))
|
||||||
self.db.query(DHTConnection).filter(DHTConnection.from_peer_id == db_peer.peer_id).delete()
|
self.db.query(DHTConnection).filter(DHTConnection.from_peer_id == db_peer.peer_id).delete()
|
||||||
self.db.add_all(connections)
|
self.db.add_all(connections)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
|
Loading…
Reference in a new issue