Skip to content

gossipsub: clean peer gater stats on inbound close - #699

Merged
MarcoPolo merged 1 commit into
masterfrom
marco/peer-gater-cleanup
May 11, 2026
Merged

MarcoPolo merged 1 commit into
masterfrom
marco/peer-gater-cleanup

Conversation

@MarcoPolo

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread peer_gater.go Outdated
}

func (pg *peerGater) OnClosedIncomingStream(p peer.ID, _ protocol.ID) {
pg.removePeerStats(p, false)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a NoOp to me as the underlying logic only decrements connected if outbound is true.

Is this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important part is this:

if st.connected == 0 {
delete(pg.peerStats, p)
}

Which will clear any state associate with the peerStats when the incoming stream is closed. This cleans up the case where we added some state due to a message on the incoming stream, but never had an outbound stream.

@MarcoPolo
MarcoPolo force-pushed the marco/fix-unwanted branch from 560b284 to 1c73fc4 Compare May 11, 2026 22:49
@MarcoPolo
MarcoPolo force-pushed the marco/peer-gater-cleanup branch from b6a0a39 to 998602b Compare May 11, 2026 22:49
Base automatically changed from marco/fix-unwanted to master May 11, 2026 22:50
@MarcoPolo
MarcoPolo merged commit 998602b into master May 11, 2026
12 of 13 checks passed
@MarcoPolo
MarcoPolo deleted the marco/peer-gater-cleanup branch May 11, 2026 22:50
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