Skip to content

Commit 0cb3ae5

Browse files
committed
wip
1 parent 9ed86d2 commit 0cb3ae5

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

vms/platformvm/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ type Client interface {
7878
GetCurrentValidators(ctx context.Context, subnetID ids.ID, nodeIDs []ids.NodeID, options ...rpc.Option) ([]ClientPermissionlessValidator, error)
7979
// GetPendingValidators returns the list of pending validators for subnet with ID [subnetID]
8080
GetPendingValidators(ctx context.Context, subnetID ids.ID, nodeIDs []ids.NodeID, options ...rpc.Option) ([]interface{}, []interface{}, error)
81-
// GetCurrentSupply returns an upper bound on the supply of AVAX in the system
82-
GetCurrentSupply(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, error)
81+
// GetCurrentSupply returns an upper bound on the supply of AVAX in the system along with the P-chain height
82+
GetCurrentSupply(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, uint64, error)
8383
// SampleValidators returns the nodeIDs of a sample of [sampleSize] validators from the current validator set for subnet with ID [subnetID]
8484
SampleValidators(ctx context.Context, subnetID ids.ID, sampleSize uint16, options ...rpc.Option) ([]ids.NodeID, error)
8585
// AddValidator issues a transaction to add a validator to the primary network
@@ -455,12 +455,12 @@ func (c *client) GetPendingValidators(
455455
return res.Validators, res.Delegators, err
456456
}
457457

458-
func (c *client) GetCurrentSupply(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, error) {
458+
func (c *client) GetCurrentSupply(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, uint64, error) {
459459
res := &GetCurrentSupplyReply{}
460460
err := c.requester.SendRequest(ctx, "platform.getCurrentSupply", &GetCurrentSupplyArgs{
461461
SubnetID: subnetID,
462462
}, res, options...)
463-
return uint64(res.Supply), err
463+
return uint64(res.Supply), uint64(res.Height), err
464464
}
465465

466466
func (c *client) SampleValidators(ctx context.Context, subnetID ids.ID, sampleSize uint16, options ...rpc.Option) ([]ids.NodeID, error) {

vms/platformvm/service.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,18 +1082,30 @@ type GetCurrentSupplyArgs struct {
10821082
// GetCurrentSupplyReply are the results from calling GetCurrentSupply
10831083
type GetCurrentSupplyReply struct {
10841084
Supply json.Uint64 `json:"supply"`
1085+
Height json.Uint64 `json:"height"`
10851086
}
10861087

10871088
// GetCurrentSupply returns an upper bound on the supply of AVAX in the system
1088-
func (s *Service) GetCurrentSupply(_ *http.Request, args *GetCurrentSupplyArgs, reply *GetCurrentSupplyReply) error {
1089+
func (s *Service) GetCurrentSupply(r *http.Request, args *GetCurrentSupplyArgs, reply *GetCurrentSupplyReply) error {
10891090
s.vm.ctx.Log.Debug("API called",
10901091
zap.String("service", "platform"),
10911092
zap.String("method", "getCurrentSupply"),
10921093
)
10931094

10941095
supply, err := s.vm.state.GetCurrentSupply(args.SubnetID)
1096+
if err != nil {
1097+
return fmt.Errorf("fetching current supply failed: %w", err)
1098+
}
10951099
reply.Supply = json.Uint64(supply)
1096-
return err
1100+
1101+
ctx := r.Context()
1102+
height, err := s.vm.GetCurrentHeight(ctx)
1103+
if err != nil {
1104+
return fmt.Errorf("fetching current height failed: %w", err)
1105+
}
1106+
reply.Height = json.Uint64(height)
1107+
1108+
return nil
10971109
}
10981110

10991111
// SampleValidatorsArgs are the arguments for calling SampleValidators

0 commit comments

Comments
 (0)