Merge pull request #1951 from rlan35/staking_final_final

Use one1 address for staking rpcs.
pull/1955/head
Rongjian Lan 5 years ago committed by GitHub
commit 490804fa84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      internal/hmyapi/blockchain.go
  2. 9
      internal/hmyapi/types.go

@ -492,13 +492,23 @@ func (s *PublicBlockChainAPI) LatestHeader(ctx context.Context) *HeaderInformati
}
// GetAllValidatorAddresses returns all validator addresses.
func (s *PublicBlockChainAPI) GetAllValidatorAddresses() ([]common.Address, error) {
return s.b.GetAllValidatorAddresses(), nil
func (s *PublicBlockChainAPI) GetAllValidatorAddresses() ([]string, error) {
addresses := []string{}
for _, addr := range s.b.GetAllValidatorAddresses() {
oneAddr, _ := internal_common.AddressToBech32(addr)
addresses = append(addresses, oneAddr)
}
return addresses, nil
}
// GetActiveValidatorAddresses returns active validator addresses.
func (s *PublicBlockChainAPI) GetActiveValidatorAddresses() ([]common.Address, error) {
return s.b.GetActiveValidatorAddresses(), nil
func (s *PublicBlockChainAPI) GetActiveValidatorAddresses() ([]string, error) {
addresses := []string{}
for _, addr := range s.b.GetActiveValidatorAddresses() {
oneAddr, _ := internal_common.AddressToBech32(addr)
addresses = append(addresses, oneAddr)
}
return addresses, nil
}
// GetValidatorInformation returns information about a validator.
@ -562,9 +572,11 @@ func (s *PublicBlockChainAPI) GetDelegationsByDelegator(ctx context.Context, add
delegation.Undelegations[j].Epoch,
})
}
valAddr, _ := internal_common.AddressToBech32(validators[i])
delAddr, _ := internal_common.AddressToBech32(delegatorAddress)
result = append(result, &RPCDelegation{
validators[i],
delegatorAddress,
valAddr,
delAddr,
delegation.Amount,
delegation.Reward,
undelegations,
@ -588,9 +600,11 @@ func (s *PublicBlockChainAPI) GetDelegationsByValidator(ctx context.Context, add
delegation.Undelegations[j].Epoch,
})
}
valAddr, _ := internal_common.AddressToBech32(validatorAddress)
delAddr, _ := internal_common.AddressToBech32(delegation.DelegatorAddress)
result = append(result, &RPCDelegation{
validatorAddress,
delegation.DelegatorAddress,
valAddr,
delAddr,
delegation.Amount,
delegation.Reward,
undelegations,
@ -618,9 +632,11 @@ func (s *PublicBlockChainAPI) GetDelegationByDelegatorAndValidator(ctx context.C
delegation.Undelegations[j].Epoch,
})
}
valAddr, _ := internal_common.AddressToBech32(validatorAddress)
delAddr, _ := internal_common.AddressToBech32(delegatorAddress)
return &RPCDelegation{
validatorAddress,
delegatorAddress,
valAddr,
delAddr,
delegation.Amount,
delegation.Reward,
undelegations,

@ -83,7 +83,7 @@ type HeaderInformation struct {
// RPCValidator represents a validator
type RPCValidator struct {
Address common.Address `json:"address"`
Address string `json:"address"`
SlotPubKeys []shard.BlsPublicKey `json:"slot_pub_keys"`
SlotShardIDs []int `json:"slot_shard_ids"`
UnbondingHeight *big.Int `json:"unbonding_height"`
@ -100,8 +100,8 @@ type RPCValidator struct {
// RPCDelegation represents a particular delegation to a validator
type RPCDelegation struct {
ValidatorAddress common.Address `json:"validator_address" yaml:"validator_address"`
DelegatorAddress common.Address `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress string `json:"validator_address" yaml:"validator_address"`
DelegatorAddress string `json:"delegator_address" yaml:"delegator_address"`
Amount *big.Int `json:"amount" yaml:"amount"`
Reward *big.Int `json:"reward" yaml:"reward"`
Undelegations []RPCUndelegation `json:"Undelegations" yaml:"Undelegations"`
@ -172,8 +172,9 @@ func newRPCCXReceipt(cx *types.CXReceipt, blockHash common.Hash, blockNumber uin
}
func newRPCValidator(validator *types2.Validator) *RPCValidator {
addr, _ := internal_common.AddressToBech32(validator.Address)
return &RPCValidator{
validator.Address,
addr,
validator.SlotPubKeys,
nil,
validator.UnbondingHeight,

Loading…
Cancel
Save