Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit fab5554

Browse files
authored
Merge pull request #922 from iotaledger/fix/dashboard-metrics-types
Fix dashboard metrics types
2 parents adfae08 + b8689a5 commit fab5554

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

components/dashboard_metrics/component.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ func configure() error {
7575
routeGroup := deps.RestRouteManager.AddRoute("dashboard-metrics/v2")
7676

7777
routeGroup.GET(RouteNodeInfoExtended, func(c echo.Context) error {
78-
return httpserver.JSONResponse(c, http.StatusOK, nodeInfoExtended())
78+
return responseByHeader(c, nodeInfoExtended(), http.StatusOK)
7979
})
8080

8181
routeGroup.GET(RouteDatabaseSizes, func(c echo.Context) error {
82-
return httpserver.JSONResponse(c, http.StatusOK, databaseSizesMetrics())
82+
return responseByHeader(c, databaseSizesMetrics(), http.StatusOK)
8383
})
8484

8585
routeGroup.GET(RouteGossipMetrics, func(c echo.Context) error {
86-
return httpserver.JSONResponse(c, http.StatusOK, gossipMetrics())
86+
return responseByHeader(c, gossipMetrics(), http.StatusOK)
8787
})
8888

8989
return nil
@@ -101,3 +101,7 @@ func run() error {
101101

102102
return nil
103103
}
104+
105+
func responseByHeader(c echo.Context, obj any, httpStatusCode ...int) error {
106+
return httpserver.SendResponseByHeader(c, deps.Protocol.Engines.Main.Get().CommittedAPI(), obj, httpStatusCode...)
107+
}

components/dashboard_metrics/types.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ package dashboardmetrics
22

33
// NodeInfoExtended represents extended information about the node.
44
type NodeInfoExtended struct {
5-
Version string `json:"version"`
6-
LatestVersion string `json:"latestVersion"`
7-
Uptime int64 `json:"uptime"`
8-
NodeID string `json:"nodeId"`
9-
NodeAlias string `json:"nodeAlias"`
10-
MemoryUsage int64 `json:"memUsage"`
5+
Version string `serix:",lenPrefix=uint8"`
6+
LatestVersion string `serix:",lenPrefix=uint8"`
7+
Uptime int64 `serix:""`
8+
NodeID string `serix:",lenPrefix=uint8"`
9+
NodeAlias string `serix:",lenPrefix=uint8"`
10+
MemoryUsage int64 `serix:""`
1111
}
1212

1313
// DatabaseSizesMetric represents database size metrics.
1414
type DatabaseSizesMetric struct {
15-
Permanent int64 `json:"permanent"`
16-
Prunable int64 `json:"prunable"`
17-
TxRetainer int64 `json:"txRetainer"`
18-
Total int64 `json:"total"`
19-
Time int64 `json:"ts"`
15+
Permanent int64 `serix:""`
16+
Prunable int64 `serix:""`
17+
TxRetainer int64 `serix:""`
18+
Total int64 `serix:""`
19+
Time int64 `serix:""`
2020
}
2121

2222
// GossipMetrics represents the metrics for blocks per second.
2323
type GossipMetrics struct {
24-
Incoming uint32 `json:"incoming"`
25-
New uint32 `json:"new"`
26-
Outgoing uint32 `json:"outgoing"`
24+
Incoming uint32 `serix:""`
25+
New uint32 `serix:""`
26+
Outgoing uint32 `serix:""`
2727
}

0 commit comments

Comments
 (0)