Skip to content

Commit

Permalink
Merge pull request #5469 from oasisprotocol/peternose/bugfix/ttl-over…
Browse files Browse the repository at this point in the history
…write

go/p2p/peermgmt/backup: Prevent overwriting TTL when restoring peers
  • Loading branch information
peternose authored Nov 24, 2023
2 parents 2870101 + 5031e5b commit 29e80d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changelog/5469.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/p2p/peermgmt/backup: Prevent overwriting TTL when restoring peers

If the peer address of a seed node was added to the libp2p address book
before peer manager restored backup peer addresses, its permanent TTL
was replaced with the TTL for recently connected peers.
3 changes: 2 additions & 1 deletion go/p2p/peermgmt/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func (b *peerstoreBackup) restore(ctx context.Context) error {
}

for _, info := range peers[peerstoreNamespace] {
b.store.SetAddrs(info.ID, info.Addrs, peerstore.RecentlyConnectedAddrTTL)
// Make sure to add, not set, the address to avoid overwriting the TTL.
b.store.AddAddrs(info.ID, info.Addrs, peerstore.RecentlyConnectedAddrTTL)
}

return nil
Expand Down

0 comments on commit 29e80d5

Please sign in to comment.