Remove unncessary api

pull/1866/head
Rongjian Lan 5 years ago
parent 929a44dbd5
commit b1a6c77f6b
  1. 5
      core/blockchain.go
  2. 13
      hmy/api_backend.go
  3. 2
      internal/hmyapi/backend.go
  4. 20
      internal/hmyapi/blockchain.go
  5. 1
      shard/committee/assignment.go

@ -2641,8 +2641,3 @@ func (bc *BlockChain) ValidatorCandidates() []common.Address {
func (bc *BlockChain) DelegatorsInformation(addr common.Address) []*staking.Delegation {
return make([]*staking.Delegation, 0)
}
// ValidatorStakingWithDelegation returns the amount of staking after applying all delegated stakes
func (bc *BlockChain) ValidatorStakingWithDelegation(addr common.Address) *big.Int {
return big.NewInt(0)
}

@ -351,7 +351,14 @@ func (b *APIBackend) GetDelegationsByDelegator(delegator common.Address) ([]comm
return addresses, delegations
}
// GetValidatorStakingWithDelegation returns the amount of staking after applying all delegated stakes
func (b *APIBackend) GetValidatorStakingWithDelegation(addr common.Address) *big.Int {
return b.hmy.BlockChain().ValidatorStakingWithDelegation(addr)
// GetValidatorSelfDelegation returns the amount of staking after applying all delegated stakes
func (b *APIBackend) GetValidatorSelfDelegation(addr common.Address) *big.Int {
wrapper, err := b.hmy.BlockChain().ReadValidatorData(addr)
if err != nil || wrapper == nil {
return nil
}
if len(wrapper.Delegations) == 0 {
return nil
}
return wrapper.Delegations[0].Amount
}

@ -79,7 +79,7 @@ type Backend interface {
GetValidatorStats(addr common.Address) *staking.ValidatorStats
GetDelegationsByValidator(validator common.Address) []*staking.Delegation
GetDelegationsByDelegator(delegator common.Address) ([]common.Address, []*staking.Delegation)
GetValidatorStakingWithDelegation(addr common.Address) *big.Int
GetValidatorSelfDelegation(addr common.Address) *big.Int
}
// GetAPIs returns all the APIs.

@ -300,8 +300,13 @@ func (s *PublicBlockChainAPI) GetLeader(ctx context.Context) string {
return s.LatestHeader(ctx).Leader
}
// GetStake returns validator stake.
func (s *PublicBlockChainAPI) GetStake(ctx context.Context, address string) hexutil.Uint64 {
// GetValidatorSelfDelegation returns validator stake.
func (s *PublicBlockChainAPI) GetValidatorSelfDelegation(ctx context.Context, address string) hexutil.Uint64 {
return hexutil.Uint64(s.b.GetValidatorSelfDelegation(internal_common.ParseAddr(address)).Uint64())
}
// GetValidatorSelfDelegation returns total balace stacking for validator with delegation.
func (s *PublicBlockChainAPI) GetValidatorTotalDelegation(ctx context.Context, address string) hexutil.Uint64 {
delegations := s.b.GetDelegationsByValidator(internal_common.ParseAddr(address))
totalStake := big.NewInt(0)
for _, delegation := range delegations {
@ -311,17 +316,6 @@ func (s *PublicBlockChainAPI) GetStake(ctx context.Context, address string) hexu
return hexutil.Uint64(totalStake.Uint64())
}
// GetValidatorStakingAddress stacking address returns validator stacking address.
func (s *PublicBlockChainAPI) GetValidatorStakingAddress(ctx context.Context, address string) string {
validator := s.b.GetValidatorInformation(internal_common.ParseAddr(address))
return validator.Address.String()
}
// GetValidatorStakingWithDelegation returns total balace stacking for validator with delegation.
func (s *PublicBlockChainAPI) GetValidatorStakingWithDelegation(ctx context.Context, address string) hexutil.Uint64 {
return hexutil.Uint64(s.b.GetValidatorStakingWithDelegation(internal_common.ParseAddr(address)).Uint64())
}
// GetShardingStructure returns an array of sharding structures.
func (s *PublicBlockChainAPI) GetShardingStructure(ctx context.Context) ([]map[string]interface{}, error) {
// Get header and number of shards.

@ -41,7 +41,6 @@ type Reader interface {
// StakingCandidatesReader ..
type StakingCandidatesReader interface {
ReadValidatorData(addr common.Address) (*staking.ValidatorWrapper, error)
ValidatorStakingWithDelegation(addr common.Address) *big.Int
ValidatorCandidates() []common.Address
}

Loading…
Cancel
Save