Skip to content

Commit

Permalink
Merge pull request #325 from stratosnet/fix-metrics-api
Browse files Browse the repository at this point in the history
Fix pb for metrics
  • Loading branch information
alexstratos authored Oct 31, 2023
2 parents 6e2c3cf + 9a597cc commit 2b2cc44
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 710 deletions.
73 changes: 2 additions & 71 deletions proto/stratos/pot/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -165,76 +165,7 @@ message QueryTotalRewardByEpochResponse {
message QueryMetricsRequest {}

message QueryMetricsResponse {
string total_supply = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_supply",
(gogoproto.moretags) = "yaml:\"total_supply\""
];
string total_mining_supply = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_mining_supply",
(gogoproto.moretags) = "yaml:\"total_mining_supply\""
];
string total_mined_tokens = 3 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_mined_tokens",
(gogoproto.moretags) = "yaml:\"total_mined_tokens\""
];
string total_resource_nodes_deposit = 4 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_resource_nodes_deposit",
(gogoproto.moretags) = "yaml:\"total_resource_nodes_deposit\""
];
string total_bonded_delegation = 5 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_bonded_delegation",
(gogoproto.moretags) = "yaml:\"total_bonded_delegation\""
];
string total_unbonded_delegation = 6 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_unbonded_delegation",
(gogoproto.moretags) = "yaml:\"total_unbonded_delegation\""
];
string total_unbonding_delegation = 7 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_unbonding_delegation",
(gogoproto.moretags) = "yaml:\"total_unbonding_delegation\""
];
string circulation_supply = 8 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "circulation_supply",
(gogoproto.moretags) = "yaml:\"circulation_supply\""
];
string total_mining_reward = 9 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "total_mining_reward",
(gogoproto.moretags) = "yaml:\"total_mining_reward\""
];
string chain_mining_reward = 10 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "chain_mining_reward",
(gogoproto.moretags) = "yaml:\"chain_mining_reward\""
];
string resource_mining_reward = 11 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "resource_mining_reward",
(gogoproto.moretags) = "yaml:\"resource_mining_reward\""
];
string meta_mining_reward = 12 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.jsontag) = "meta_mining_reward",
(gogoproto.moretags) = "yaml:\"meta_mining_reward\""
Metrics metrics = 1 [
(gogoproto.nullable) = false
];
}
13 changes: 1 addition & 12 deletions x/pot/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,17 +409,6 @@ func (q Querier) Metrics(c context.Context, req *types.QueryMetricsRequest) (

metrics := q.GetMetrics(ctx)
return &types.QueryMetricsResponse{
TotalSupply: metrics.TotalSupply,
TotalMiningSupply: metrics.TotalMiningSupply,
TotalMinedTokens: metrics.TotalMinedTokens,
TotalResourceNodesDeposit: metrics.TotalResourceNodesDeposit,
TotalBondedDelegation: metrics.TotalBondedDelegation,
TotalUnbondedDelegation: metrics.TotalUnbondedDelegation,
TotalUnbondingDelegation: metrics.TotalUnbondingDelegation,
CirculationSupply: metrics.CirculationSupply,
TotalMiningReward: metrics.TotalMiningReward,
ChainMiningReward: metrics.ChainMiningReward,
ResourceMiningReward: metrics.ResourceMiningReward,
MetaMiningReward: metrics.MetaMiningReward,
Metrics: metrics,
}, nil
}
4 changes: 2 additions & 2 deletions x/pot/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (k Keeper) GetTotalReward(ctx sdk.Context, epoch sdk.Int) (totalReward type
return
}

func (k Keeper) GetMetrics(ctx sdk.Context) *types.Metrics {
func (k Keeper) GetMetrics(ctx sdk.Context) types.Metrics {
totalSupply := k.bankKeeper.GetSupply(ctx, k.BondDenom(ctx))
totalMining := k.GetTotalMining(ctx)
totalMinedTokens := k.GetTotalMinedTokens(ctx)
Expand Down Expand Up @@ -283,7 +283,7 @@ func (k Keeper) GetMetrics(ctx sdk.Context) *types.Metrics {
metaMiningReward = totalMiningReward.Mul(miningParam.MetaNodePercentageInBp).Quo(sdk.NewInt(10000))
}

return &types.Metrics{
return types.Metrics{
TotalSupply: totalSupply.Amount,
TotalMiningSupply: totalMining.Amount,
TotalMinedTokens: totalMinedTokens.Amount,
Expand Down
Loading

0 comments on commit 2b2cc44

Please sign in to comment.