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

Add external multiaddress to NodeInfoExtended #969

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion components/dashboard_metrics/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ func nodeInfoExtended() *NodeInfoExtended {
var m runtime.MemStats
runtime.ReadMemStats(&m)

getExternalMultiAddr := func() string {
var fallback string

for i, addr := range deps.Host.Addrs() {
if i == 0 {
fallback = addr.String()
}

for _, protocol := range addr.Protocols() {
// search the first dns address
if protocol.Name == "dns" {
return addr.String()
}
}
}

return fallback
}

status := &NodeInfoExtended{
Version: deps.AppInfo.Version,
LatestVersion: deps.AppInfo.LatestGitHubVersion,
Uptime: time.Since(nodeStartupTimestamp).Milliseconds(),
NodeID: deps.Host.ID().String(),
NodeAlias: ParamsNode.Alias,
MultiAddress: getExternalMultiAddr(),
Alias: ParamsNode.Alias,
MemoryUsage: int64(m.HeapAlloc + m.StackSys + m.MSpanSys + m.MCacheSys + m.BuckHashSys + m.GCSys + m.OtherSys),
}

Expand Down
3 changes: 2 additions & 1 deletion components/dashboard_metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ type NodeInfoExtended struct {
LatestVersion string `serix:",lenPrefix=uint8"`
Uptime int64 `serix:""`
NodeID string `serix:",lenPrefix=uint8"`
NodeAlias string `serix:",lenPrefix=uint8"`
MultiAddress string `serix:",lenPrefix=uint8"`
Alias string `serix:",lenPrefix=uint8"`
MemoryUsage int64 `serix:""`
}

Expand Down
1 change: 1 addition & 0 deletions tools/docker-network/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mkdir -p docker-network-snapshots/
chmod o+w docker-network-snapshots/

# Allow docker compose to build and cache an image
echo "Building docker image"
echo $DOCKER_BUILD_CONTEXT $DOCKERFILE_PATH
docker compose build --build-arg WITH_GO_WORK=${WITH_GO_WORK:-0} --build-arg DOCKER_BUILD_CONTEXT=${DOCKER_BUILD_CONTEXT} --build-arg DOCKERFILE_PATH=${DOCKERFILE_PATH}

Expand Down
Loading