Skip to content

Commit

Permalink
fix(db): update port and services for gossiped peers in `StatelessPee…
Browse files Browse the repository at this point in the history
…rStore`
  • Loading branch information
rustaceanrob committed Jan 9, 2025
1 parent 3cf1220 commit abbd48e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/db/memory/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ impl StatelessPeerStore {
}

async fn update(&mut self, peer: PersistedPeer) -> Result<(), StatelessPeerStoreError> {
// Don't add back peers we already connected to this session.
match peer.status {
PeerStatus::New => {
self.list.entry(peer.clone().addr).or_insert(peer);
self.list
.entry(peer.clone().addr)
.and_modify(|stored| {
stored.port = peer.port;
stored.services = peer.services;
})
.or_insert(peer);
Ok(())
}
PeerStatus::Tried => Ok(()),
Expand Down

0 comments on commit abbd48e

Please sign in to comment.