Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swarm: add ip_version to metrics #2114

Merged
merged 2 commits into from
Feb 18, 2023

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Feb 17, 2023

fixes: #2106

@sukunrt sukunrt force-pushed the swarm-metrics-ip-version branch from 247e458 to ae2b077 Compare February 17, 2023 06:07
@sukunrt sukunrt marked this pull request as draft February 17, 2023 06:08
@sukunrt sukunrt force-pushed the swarm-metrics-ip-version branch from ae2b077 to dd397d4 Compare February 17, 2023 06:31
@sukunrt sukunrt force-pushed the swarm-metrics-ip-version branch from dd397d4 to a54bcaf Compare February 17, 2023 06:34
@sukunrt sukunrt marked this pull request as ready for review February 17, 2023 07:09
Comment on lines +113 to +122
ma.ForEach(addr, func(c ma.Component) bool {
if c.Protocol().Code == ma.P_IP4 {
version = "ip4"
return false
} else if c.Protocol().Code == ma.P_IP6 {
version = "ip6"
return false
}
return true
})
Copy link
Member Author

Choose a reason for hiding this comment

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

@marten-seemann addr.ValueForProtocol(ma.P_IP4) allocates on heap, so doing it this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that's fine. Our multiaddr API isn't the cleanest...

p2p/net/swarm/swarm_metrics.go Outdated Show resolved Hide resolved
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.

swarm metrics: keep track of IP version
2 participants