Skip to content

Commit

Permalink
feat: allow setting historical validators bulk count
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Jul 31, 2023
1 parent 28fa343 commit c22466e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
21 changes: 13 additions & 8 deletions pkg/config/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ import (
"gopkg.in/guregu/null.v4"
)

type ChainPagination struct {
HistoricalValidators int `default:"100" toml:"historical-validators"`
}

type ChainConfig struct {
Name string `toml:"name"`
PrettyName string `toml:"pretty-name"`
RPCEndpoints []string `toml:"rpc-endpoints"`
StoreBlocks int64 `default:"20000" toml:"store-blocks"`
BlocksWindow int64 `default:"10000" toml:"blocks-window"`
MinSignedPerWindow float64 `default:"0.05" toml:"min-signed-per-window"`
QueryEachSigningInfo null.Bool `default:"false" toml:"query-each-signing-info"`
QuerySlashingParams null.Bool `default:"true" toml:"query-slashing-params"`
Name string `toml:"name"`
PrettyName string `toml:"pretty-name"`
RPCEndpoints []string `toml:"rpc-endpoints"`
StoreBlocks int64 `default:"20000" toml:"store-blocks"`
BlocksWindow int64 `default:"10000" toml:"blocks-window"`
MinSignedPerWindow float64 `default:"0.05" toml:"min-signed-per-window"`
QueryEachSigningInfo null.Bool `default:"false" toml:"query-each-signing-info"`
QuerySlashingParams null.Bool `default:"true" toml:"query-slashing-params"`
Pagination ChainPagination `toml:"pagination"`

IsConsumer null.Bool `default:"false" toml:"consumer"`
ProviderRPCEndpoints []string `toml:"provider-rpc-endpoints"`
Expand Down
2 changes: 0 additions & 2 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const (
BlockSearchPagination int64 = 100
ValidatorsQueryPagination uint64 = 1000
SigningInfosQueryPagination uint64 = 1000
ActiveSetPagination int = 100
ActiveSetsBulkQueryCount int64 = 50

NewBlocksQuery = "tm.event='NewBlock'"

Expand Down
4 changes: 2 additions & 2 deletions pkg/tendermint/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (rpc *RPC) GetActiveSetAtBlock(height int64) (map[string]bool, error) {
queryURL := fmt.Sprintf(
"/validators?height=%d&per_page=%d&page=%d",
height,
constants.ActiveSetPagination,
rpc.config.Pagination.HistoricalValidators,
page,
)

Expand Down Expand Up @@ -268,7 +268,7 @@ func (rpc *RPC) GetActiveSetAtBlock(height int64) (map[string]bool, error) {
activeSetMap[validator.Address] = true
}

if len(response.Result.Validators) < constants.ActiveSetPagination {
if len(response.Result.Validators) < rpc.config.Pagination.HistoricalValidators {
break
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/types/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type ValidatorsResponse struct {

type ValidatorsResult struct {
Validators []HistoricalValidator `json:"validators"`
Count string `json:"count"`
Total string `json:"total"`
}

type HistoricalValidator struct {
Expand Down

0 comments on commit c22466e

Please sign in to comment.