Merge branch 'add-address-get-validators' into denali

This commit is contained in:
StephenButtolph 2020-05-30 16:04:58 -04:00
commit d088a9b29a
2 changed files with 25 additions and 3 deletions

View File

@ -148,11 +148,22 @@ func (service *Service) GetCurrentValidators(_ *http.Request, args *GetCurrentVa
vdr := tx.Vdr()
weight := json.Uint64(vdr.Weight())
if args.SubnetID.Equals(DefaultSubnetID) {
var address ids.ShortID
switch tx := tx.(type) {
case *addDefaultSubnetValidatorTx:
address = tx.Destination
case *addDefaultSubnetDelegatorTx:
address = tx.Destination
default: // Shouldn't happen
return fmt.Errorf("couldn't get the destination address of %s", tx.ID())
}
reply.Validators[i] = APIValidator{
ID: vdr.ID(),
StartTime: json.Uint64(tx.StartTime().Unix()),
EndTime: json.Uint64(tx.EndTime().Unix()),
StakeAmount: &weight,
Address: &address,
}
} else {
reply.Validators[i] = APIValidator{
@ -197,11 +208,21 @@ func (service *Service) GetPendingValidators(_ *http.Request, args *GetPendingVa
vdr := tx.Vdr()
weight := json.Uint64(vdr.Weight())
if args.SubnetID.Equals(DefaultSubnetID) {
var address ids.ShortID
switch tx := tx.(type) {
case *addDefaultSubnetValidatorTx:
address = tx.Destination
case *addDefaultSubnetDelegatorTx:
address = tx.Destination
default: // Shouldn't happen
return fmt.Errorf("couldn't get the destination address of %s", tx.ID())
}
reply.Validators[i] = APIValidator{
ID: vdr.ID(),
StartTime: json.Uint64(tx.StartTime().Unix()),
EndTime: json.Uint64(tx.EndTime().Unix()),
StakeAmount: &weight,
Address: &address,
}
} else {
reply.Validators[i] = APIValidator{

View File

@ -40,13 +40,14 @@ type APIAccount struct {
// [Amount] is the amount of $AVA being staked.
// [Endtime] is the Unix time repr. of when they are done staking
// [ID] is the node ID of the staker
// [Destination] is the address where the staked $AVA (and, if applicable, reward)
// [Address] is the address where the staked AVA (and, if applicable, reward)
// is sent when this staker is done staking.
type APIValidator struct {
StartTime json.Uint64 `json:"startTime"`
EndTime json.Uint64 `json:"endTime"`
Weight *json.Uint64 `json:"weight,omitempty"`
StakeAmount *json.Uint64 `json:"stakeAmount,omitempty"`
Address *ids.ShortID `json:"address,omitempty"`
ID ids.ShortID `json:"id"`
}
@ -137,8 +138,8 @@ func (*StaticService) BuildGenesis(_ *http.Request, args *BuildGenesisArgs, repl
return errAccountHasNoValue
}
accounts = append(accounts, newAccount(
account.Address, // ID
0, // nonce
account.Address, // ID
0, // nonce
uint64(account.Balance), // balance
))
}