Skip to content

Conversation

@vipocenka
Copy link
Contributor

What

  • Peer.Caps() now returns a copy of the internal slice to prevent callers from mutating it.
  • Added TestCapsReturnsCopy to verify this behavior.

Why
This closes the outstanding TODO in p2p/peer.go and ensures that external code cannot accidentally change a peer’s advertised capabilities.

Checklist

  • go fmt and go vet pass
  • All p2p tests (including the new one) pass
  • No new lint or race detector warnings

@fjl
Copy link
Contributor

fjl commented Aug 7, 2025

I think this change is not needed. Caps has a total of two callsites within go-ethereum, and one of them is for logging.

@fjl fjl closed this Aug 7, 2025
cuiweixie added a commit to cuiweixie/go-ethereum that referenced this pull request Aug 12, 2025
lightclient pushed a commit that referenced this pull request Aug 21, 2025
as metioned in #32351, I
think this comment is unnecessary.
gballet pushed a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
as metioned in ethereum#32351, I
think this comment is unnecessary.
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.

2 participants