Merge branch 'staking_last_push' of github.com:rlan35/harmony into staking_last_push

pull/1903/head
Rongjian Lan 5 years ago
commit e206fd291e
  1. 6
      hmy/api_backend.go
  2. 2
      internal/hmyapi/backend.go
  3. 6
      internal/hmyapi/blockchain.go

@ -364,10 +364,10 @@ func (b *APIBackend) GetValidatorSelfDelegation(addr common.Address) *big.Int {
}
// GetShardState ...
func (b *APIBackend) GetShardState() *shard.State {
func (b *APIBackend) GetShardState() (shard.State, error) {
state, err := b.hmy.BlockChain().ReadShardState(b.hmy.BlockChain().CurrentHeader().Epoch())
if err != nil {
return &shard.State{}
return nil, errors.Wrapf(err, "cannot read from DB")
}
return &state
return state, nil
}

@ -80,7 +80,7 @@ type Backend interface {
GetDelegationsByValidator(validator common.Address) []*staking.Delegation
GetDelegationsByDelegator(delegator common.Address) ([]common.Address, []*staking.Delegation)
GetValidatorSelfDelegation(addr common.Address) *big.Int
GetShardState() *shard.State
GetShardState() (shard.State, error)
}
// GetAPIs returns all the APIs.

@ -518,11 +518,11 @@ func (s *PublicBlockChainAPI) GetValidatorInformation(ctx context.Context, addre
rpcValidator.TotalEffectiveStake = stats.TotalEffectiveStake.String()
}
shardState := s.b.GetShardState()
if shardState != nil {
shardState, err := s.b.GetShardState()
if err == nil {
blsKeyToShardID := make(map[shard.BlsPublicKey]uint32)
for _, committee := range *shardState {
for _, committee := range shardState {
for _, slot := range committee.Slots {
blsKeyToShardID[slot.BlsPublicKey] = committee.ShardID
}

Loading…
Cancel
Save