|
|
|
@ -63,6 +63,36 @@ func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, blockHash comm |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetCommittee returns committee for a particular epoch.
|
|
|
|
|
func (s *PublicBlockChainAPI) GetCommittee(ctx context.Context, epoch int64) (map[string]interface{}, error) { |
|
|
|
|
committee, err := s.b.GetCommittee(big.NewInt(epoch)) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
validators := make([]map[string]interface{}, 0) |
|
|
|
|
for _, validator := range committee.NodeList { |
|
|
|
|
validatorBalance := new(hexutil.Big) |
|
|
|
|
validatorBalance, err = s.b.GetBalance(validator.EcdsaAddress) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
oneAddress, err := internal_common.AddressToBech32(validator.EcdsaAddress) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
validatorsFields := map[string]interface{}{ |
|
|
|
|
"address": oneAddress, |
|
|
|
|
"balance": validatorBalance, |
|
|
|
|
} |
|
|
|
|
validators = append(validators, validatorsFields) |
|
|
|
|
} |
|
|
|
|
result := map[string]interface{}{ |
|
|
|
|
"shardID": committee.ShardID, |
|
|
|
|
"validators": validators, |
|
|
|
|
} |
|
|
|
|
return result, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetShardingStructure returns an array of sharding structures.
|
|
|
|
|
func (s *PublicBlockChainAPI) GetShardingStructure(ctx context.Context) ([]map[string]interface{}, error) { |
|
|
|
|
// Get header and number of shards.
|
|
|
|
|