|
|
@ -627,7 +627,7 @@ func (s *PublicBlockChainAPI) GetElectedValidatorAddresses() ([]string, error) { |
|
|
|
// GetValidatorInformation returns information about a validator.
|
|
|
|
// GetValidatorInformation returns information about a validator.
|
|
|
|
func (s *PublicBlockChainAPI) GetValidatorInformation( |
|
|
|
func (s *PublicBlockChainAPI) GetValidatorInformation( |
|
|
|
ctx context.Context, address string, |
|
|
|
ctx context.Context, address string, |
|
|
|
) (*staking.ValidatorRPCEnchanced, error) { |
|
|
|
) (*staking.ValidatorRPCEnhanced, error) { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -643,7 +643,7 @@ func (s *PublicBlockChainAPI) GetValidatorInformation( |
|
|
|
// GetValidatorInformationByBlockNumber returns information about a validator.
|
|
|
|
// GetValidatorInformationByBlockNumber returns information about a validator.
|
|
|
|
func (s *PublicBlockChainAPI) GetValidatorInformationByBlockNumber( |
|
|
|
func (s *PublicBlockChainAPI) GetValidatorInformationByBlockNumber( |
|
|
|
ctx context.Context, address string, blockNr rpc.BlockNumber, |
|
|
|
ctx context.Context, address string, blockNr rpc.BlockNumber, |
|
|
|
) (*staking.ValidatorRPCEnchanced, error) { |
|
|
|
) (*staking.ValidatorRPCEnhanced, error) { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -661,13 +661,13 @@ func (s *PublicBlockChainAPI) GetValidatorInformationByBlockNumber( |
|
|
|
|
|
|
|
|
|
|
|
func (s *PublicBlockChainAPI) getAllValidatorInformation( |
|
|
|
func (s *PublicBlockChainAPI) getAllValidatorInformation( |
|
|
|
ctx context.Context, page int, blockNr rpc.BlockNumber, |
|
|
|
ctx context.Context, page int, blockNr rpc.BlockNumber, |
|
|
|
) ([]*staking.ValidatorRPCEnchanced, error) { |
|
|
|
) ([]*staking.ValidatorRPCEnhanced, error) { |
|
|
|
if page < -1 { |
|
|
|
if page < -1 { |
|
|
|
return nil, errors.Errorf("page given %d cannot be less than -1", page) |
|
|
|
return nil, errors.Errorf("page given %d cannot be less than -1", page) |
|
|
|
} |
|
|
|
} |
|
|
|
addresses := s.b.GetAllValidatorAddresses() |
|
|
|
addresses := s.b.GetAllValidatorAddresses() |
|
|
|
if page != -1 && len(addresses) <= page*validatorsPageSize { |
|
|
|
if page != -1 && len(addresses) <= page*validatorsPageSize { |
|
|
|
return make([]*staking.ValidatorRPCEnchanced, 0), nil |
|
|
|
return make([]*staking.ValidatorRPCEnhanced, 0), nil |
|
|
|
} |
|
|
|
} |
|
|
|
validatorsNum := len(addresses) |
|
|
|
validatorsNum := len(addresses) |
|
|
|
start := 0 |
|
|
|
start := 0 |
|
|
@ -678,7 +678,7 @@ func (s *PublicBlockChainAPI) getAllValidatorInformation( |
|
|
|
validatorsNum = len(addresses) - start |
|
|
|
validatorsNum = len(addresses) - start |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
validators := make([]*staking.ValidatorRPCEnchanced, validatorsNum) |
|
|
|
validators := make([]*staking.ValidatorRPCEnhanced, validatorsNum) |
|
|
|
block, err := s.b.BlockByNumber(ctx, rpc.BlockNumber(blockNr)) |
|
|
|
block, err := s.b.BlockByNumber(ctx, rpc.BlockNumber(blockNr)) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, errors.Wrapf(err, "could not retrieve the block information for block number: %d", blockNr) |
|
|
|
return nil, errors.Wrapf(err, "could not retrieve the block information for block number: %d", blockNr) |
|
|
@ -697,7 +697,7 @@ func (s *PublicBlockChainAPI) getAllValidatorInformation( |
|
|
|
// If page is -1, return all instead of `validatorsPageSize` elements.
|
|
|
|
// If page is -1, return all instead of `validatorsPageSize` elements.
|
|
|
|
func (s *PublicBlockChainAPI) GetAllValidatorInformation( |
|
|
|
func (s *PublicBlockChainAPI) GetAllValidatorInformation( |
|
|
|
ctx context.Context, page int, |
|
|
|
ctx context.Context, page int, |
|
|
|
) ([]*staking.ValidatorRPCEnchanced, error) { |
|
|
|
) ([]*staking.ValidatorRPCEnhanced, error) { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -717,14 +717,14 @@ func (s *PublicBlockChainAPI) GetAllValidatorInformation( |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
return res.([]*staking.ValidatorRPCEnchanced), nil |
|
|
|
return res.([]*staking.ValidatorRPCEnhanced), nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetAllValidatorInformationByBlockNumber returns information about all validators.
|
|
|
|
// GetAllValidatorInformationByBlockNumber returns information about all validators.
|
|
|
|
// If page is -1, return all instead of `validatorsPageSize` elements.
|
|
|
|
// If page is -1, return all instead of `validatorsPageSize` elements.
|
|
|
|
func (s *PublicBlockChainAPI) GetAllValidatorInformationByBlockNumber( |
|
|
|
func (s *PublicBlockChainAPI) GetAllValidatorInformationByBlockNumber( |
|
|
|
ctx context.Context, page int, blockNr rpc.BlockNumber, |
|
|
|
ctx context.Context, page int, blockNr rpc.BlockNumber, |
|
|
|
) ([]*staking.ValidatorRPCEnchanced, error) { |
|
|
|
) ([]*staking.ValidatorRPCEnhanced, error) { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
if err := s.isBeaconShard(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|