Skip to content

Commit

Permalink
Add external MultiAddress to NodeInfoExtended
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed May 14, 2024
1 parent 857a7cd commit 0d7d03f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
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

0 comments on commit 0d7d03f

Please sign in to comment.