Skip to content

Commit

Permalink
Add json tags for API structs that are used in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Apr 18, 2024
1 parent 9fa0d41 commit 6a625ac
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
54 changes: 27 additions & 27 deletions api/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,77 +462,77 @@ type (
// InfoResponse defines the response of a GET info REST API call.
InfoResponse struct {
// The name of the node software.
Name string `serix:",lenPrefix=uint8"`
Name string `serix:",lenPrefix=uint8" json:"name"`
// The semver version of the node software.
Version string `serix:",lenPrefix=uint8"`
Version string `serix:",lenPrefix=uint8" json:"version"`
// The current status of this node.
Status *InfoResNodeStatus `serix:""`
Status *InfoResNodeStatus `serix:"" json:"status"`
// The protocol parameters used by this node.
ProtocolParameters []*InfoResProtocolParameters `serix:",lenPrefix=uint8"`
ProtocolParameters []*InfoResProtocolParameters `serix:",lenPrefix=uint8" json:"protocolParameters"`
// The base token of the network.
BaseToken *InfoResBaseToken `serix:""`
BaseToken *InfoResBaseToken `serix:"" json:"baseToken"`
}

// InfoResProtocolParameters defines the protocol parameters of a node in the InfoResponse.
InfoResProtocolParameters struct {
StartEpoch iotago.EpochIndex `serix:""`
Parameters iotago.ProtocolParameters `serix:""`
StartEpoch iotago.EpochIndex `serix:"" json:"startEpoch"`
Parameters iotago.ProtocolParameters `serix:"" json:"parameters"`
}

// InfoResNodeStatus defines the status of the node in the InfoResponse.
InfoResNodeStatus struct {
// Whether the node is healthy.
IsHealthy bool `serix:""`
IsHealthy bool `serix:"" json:"isHealthy"`
// Whether the network is healthy (finalization is not delayed).
IsNetworkHealthy bool `serix:""`
IsNetworkHealthy bool `serix:"" json:"isNetworkHealthy"`
// The accepted tangle time.
AcceptedTangleTime time.Time `serix:""`
AcceptedTangleTime time.Time `serix:"" json:"acceptedTangleTime"`
// The relative accepted tangle time.
RelativeAcceptedTangleTime time.Time `serix:""`
RelativeAcceptedTangleTime time.Time `serix:"" json:"relativeAcceptedTangleTime"`
// The confirmed tangle time.
ConfirmedTangleTime time.Time `serix:""`
ConfirmedTangleTime time.Time `serix:"" json:"confirmedTangleTime"`
// The relative confirmed tangle time.
RelativeConfirmedTangleTime time.Time `serix:""`
RelativeConfirmedTangleTime time.Time `serix:"" json:"relativeConfirmedTangleTime"`
// The id of the latest known commitment.
LatestCommitmentID iotago.CommitmentID `serix:""`
LatestCommitmentID iotago.CommitmentID `serix:"" json:"latestCommitmentId"`
// The latest finalized slot.
LatestFinalizedSlot iotago.SlotIndex `serix:""`
LatestFinalizedSlot iotago.SlotIndex `serix:"" json:"latestFinalizedSlot"`
// The slot of the latest accepted block.
LatestAcceptedBlockSlot iotago.SlotIndex `serix:""`
LatestAcceptedBlockSlot iotago.SlotIndex `serix:"" json:"latestAcceptedBlockSlot"`
// The slot of the latest confirmed block.
LatestConfirmedBlockSlot iotago.SlotIndex `serix:""`
LatestConfirmedBlockSlot iotago.SlotIndex `serix:"" json:"latestConfirmedBlockSlot"`
// The epoch at which the tangle data was pruned.
PruningEpoch iotago.EpochIndex `serix:""`
PruningEpoch iotago.EpochIndex `serix:"" json:"pruningEpoch"`
}

// InfoResBaseToken defines the base token of the node in the InfoResponse.
InfoResBaseToken struct {
// The base token name.
Name string `serix:",lenPrefix=uint8"`
Name string `serix:",lenPrefix=uint8" json:"name"`
// The base token ticker symbol.
TickerSymbol string `serix:",lenPrefix=uint8"`
TickerSymbol string `serix:",lenPrefix=uint8" json:"tickerSymbol"`
// The base token unit.
Unit string `serix:",lenPrefix=uint8"`
Unit string `serix:",lenPrefix=uint8" json:"unit"`
// The base token subunit.
Subunit string `serix:",lenPrefix=uint8,omitempty"`
Subunit string `serix:",lenPrefix=uint8,omitempty" json:"subunit"`
// The base token amount of decimals.
Decimals uint32 `serix:""`
Decimals uint32 `serix:"" json:"decimals"`
}

// NetworkHealthResponse defines the network health response.
NetworkHealthResponse struct {
// Whether the network is healthy (finalization is not delayed).
IsNetworkHealthy bool `serix:""`
IsNetworkHealthy bool `serix:"" json:"isNetworkHealthy"`
}

// NetworkMetricsResponse defines the network metrics response.
NetworkMetricsResponse struct {
// The current rate of new blocks per second, it's updated when a commitment is committed.
BlocksPerSecond float64 `serix:""`
BlocksPerSecond float64 `serix:"" json:"blocksPerSecond"`
// The current rate of confirmed blocks per second, it's updated when a commitment is committed.
ConfirmedBlocksPerSecond float64 `serix:""`
ConfirmedBlocksPerSecond float64 `serix:"" json:"confirmedBlocksPerSecond"`
// The ratio of confirmed blocks in relation to new blocks up until the latest commitment is committed.
ConfirmationRate float64 `serix:""`
ConfirmationRate float64 `serix:"" json:"confirmationRate"`
}

// IssuanceBlockHeaderResponse defines the response of a GET block issuance REST API call.
Expand Down
36 changes: 18 additions & 18 deletions api/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,66 @@ type (
// AddPeerRequest defines the request for a POST peer REST API call.
AddPeerRequest struct {
// The libp2p multi address of the peer.
MultiAddress string `serix:",lenPrefix=uint8"`
MultiAddress string `serix:",lenPrefix=uint8" json:"multiAddress"`
// The alias to identify the peer.
Alias string `serix:",lenPrefix=uint8,omitempty"`
Alias string `serix:",lenPrefix=uint8,omitempty" json:"alias"`
}

// PeerInfo defines the response of a GET peer REST API call.
PeerInfo struct {
// The libp2p identifier of the peer.
ID string `serix:",lenPrefix=uint8"`
ID string `serix:",lenPrefix=uint8" json:"id"`
// The libp2p multi addresses of the peer.
MultiAddresses []iotago.PrefixedStringUint8 `serix:",lenPrefix=uint8"`
MultiAddresses []iotago.PrefixedStringUint8 `serix:",lenPrefix=uint8" json:"multiAddresses"`
// The alias to identify the peer.
Alias string `serix:",lenPrefix=uint8,omitempty"`
Alias string `serix:",lenPrefix=uint8,omitempty" json:"alias"`
// The relation (manual, autopeered) of the peer.
Relation string `serix:",lenPrefix=uint8"`
Relation string `serix:",lenPrefix=uint8" json:"relation"`
// Whether the peer is connected.
Connected bool `serix:""`
Connected bool `serix:"" json:"connected"`
// The gossip metrics for this peer.
GossipMetrics *PeerGossipMetrics `serix:""`
GossipMetrics *PeerGossipMetrics `serix:"" json:"gossipMetrics"`
}

// PeerGossipMetrics defines the peer gossip metrics.
PeerGossipMetrics struct {
// The total amount of received packets.
PacketsReceived uint32 `serix:""`
PacketsReceived uint32 `serix:"" json:"packetsReceived"`
// The total amount of sent packets.
PacketsSent uint32 `serix:""`
PacketsSent uint32 `serix:"" json:"packetsSent"`
}

PeersResponse struct {
Peers []*PeerInfo `serix:",lenPrefix=uint8"`
Peers []*PeerInfo `serix:",lenPrefix=uint8" json:"peers"`
}

// PruneDatabaseRequest defines the request of a prune database REST API call.
PruneDatabaseRequest struct {
// The pruning target epoch.
Epoch iotago.EpochIndex `serix:",omitempty"`
Epoch iotago.EpochIndex `serix:",omitempty" json:"epoch"`
// The pruning depth.
Depth iotago.EpochIndex `serix:",omitempty"`
Depth iotago.EpochIndex `serix:",omitempty" json:"depth"`
// The target size of the database.
TargetDatabaseSize string `serix:",lenPrefix=uint8,omitempty"`
TargetDatabaseSize string `serix:",lenPrefix=uint8,omitempty" json:"targetDatabaseSize"`
}

// PruneDatabaseResponse defines the response of a prune database REST API call.
PruneDatabaseResponse struct {
// The current oldest epoch in the database.
Epoch iotago.EpochIndex `serix:""`
Epoch iotago.EpochIndex `serix:"" json:"epoch"`
}

// CreateSnapshotRequest defines the request of a create snapshot REST API call.
CreateSnapshotRequest struct {
// The slot of the snapshot.
Slot iotago.SlotIndex `serix:""`
Slot iotago.SlotIndex `serix:"" json:"slot"`
}

// CreateSnapshotResponse defines the response of a create snapshot REST API call.
CreateSnapshotResponse struct {
// The slot of the snapshot.
Slot iotago.SlotIndex `serix:""`
Slot iotago.SlotIndex `serix:"" json:"slot"`
// The file path of the snapshot file.
FilePath string `serix:",lenPrefix=uint8"`
FilePath string `serix:",lenPrefix=uint8" json:"filePath"`
}
)
4 changes: 2 additions & 2 deletions api/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ type (
// HealthResponse defines the health response.
HealthResponse struct {
// Whether the node is healthy.
IsHealthy bool `serix:""`
IsHealthy bool `serix:"" json:"isHealthy"`
}

// RoutesResponse defines the response of a GET routes REST API call.
RoutesResponse struct {
Routes []iotago.PrefixedStringUint8 `serix:",lenPrefix=uint8"`
Routes []iotago.PrefixedStringUint8 `serix:",lenPrefix=uint8" json:"routes"`
}
)

0 comments on commit 6a625ac

Please sign in to comment.