Skip to content

fix(peer-store): copy observation times from the matching address#3574

Merged
tabcat merged 3 commits into
libp2p:mainfrom
tabcat:fix/peer-store-address-observation-time
Jul 17, 2026
Merged

fix(peer-store): copy observation times from the matching address#3574
tabcat merged 3 commits into
libp2p:mainfrom
tabcat:fix/peer-store-address-observation-time

Conversation

@tabcat

@tabcat tabcat commented Jul 17, 2026

Copy link
Copy Markdown
Member

Description

Each stored address is stamped with an observed timestamp, copied from the
matching existing address so a re-stored address keeps its original time. The
lookup for the matching address named its callback parameter addr, shadowing
the address being stamped, so it compared an address to itself and always
matched the first stored address. Every address therefore inherited the first
stored address's observed time instead of its own, so a newly added multiaddr
could be expired early by maxAddressAge despite having just been observed.

Rename the callback parameter so the lookup matches by multiaddr.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

tabcat added 3 commits July 18, 2026 03:46
The lookup callback shadowed the address being stamped, so every address
inherited the first stored address's observation time instead of its own.
@tabcat
tabcat marked this pull request as ready for review July 17, 2026 22:11
@tabcat
tabcat requested a review from a team as a code owner July 17, 2026 22:11
@tabcat
tabcat merged commit 89335e3 into libp2p:main Jul 17, 2026
45 of 48 checks passed
@tabcat tabcat mentioned this pull request Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant