diff --git a/indexer/client.go b/indexer/client.go index a63bdc23..9c0a72ec 100644 --- a/indexer/client.go +++ b/indexer/client.go @@ -15,6 +15,7 @@ type IndexerClient struct { clientIdx uint8 clientName string rpcClient *rpc.BeaconClient + skipValidators bool archive bool priority int versionStr string @@ -32,11 +33,12 @@ type IndexerClient struct { lastFinalizedRoot []byte } -func newIndexerClient(clientIdx uint8, clientName string, rpcClient *rpc.BeaconClient, indexerCache *indexerCache, archive bool, priority int) *IndexerClient { +func newIndexerClient(clientIdx uint8, clientName string, rpcClient *rpc.BeaconClient, indexerCache *indexerCache, archive bool, priority int, skipValidators bool) *IndexerClient { client := IndexerClient{ clientIdx: clientIdx, clientName: clientName, rpcClient: rpcClient, + skipValidators: skipValidators, archive: archive, priority: priority, indexerCache: indexerCache, diff --git a/indexer/epoch_stats.go b/indexer/epoch_stats.go index e20a19ac..3b36becd 100644 --- a/indexer/epoch_stats.go +++ b/indexer/epoch_stats.go @@ -313,6 +313,9 @@ func (epochStats *EpochStats) ensureEpochStatsLazy(client *IndexerClient, propos func (epochStats *EpochStats) ensureValidatorStatsLazy(client *IndexerClient, stateRef string) { defer utils.HandleSubroutinePanic("ensureValidatorStatsLazy") + if client.skipValidators { + return + } epochStats.loadValidatorStats(client, stateRef) } diff --git a/indexer/indexer.go b/indexer/indexer.go index f2d610c6..823aec90 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -11,6 +11,7 @@ import ( "github.com/pk910/light-beaconchain-explorer/dbtypes" "github.com/pk910/light-beaconchain-explorer/rpc" "github.com/pk910/light-beaconchain-explorer/rpctypes" + "github.com/pk910/light-beaconchain-explorer/types" "github.com/pk910/light-beaconchain-explorer/utils" ) @@ -43,13 +44,13 @@ func NewIndexer() (*Indexer, error) { return indexer, nil } -func (indexer *Indexer) AddClient(index uint8, name string, endpoint string, archive bool, priority int, headers map[string]string) *IndexerClient { - rpcClient, err := rpc.NewBeaconClient(endpoint, name, headers) +func (indexer *Indexer) AddClient(index uint8, endpoint *types.EndpointConfig) *IndexerClient { + rpcClient, err := rpc.NewBeaconClient(endpoint.Url, endpoint.Name, endpoint.Headers) if err != nil { - logger.Errorf("error while adding client %v to indexer: %v", name, err) + logger.Errorf("error while adding client %v to indexer: %v", endpoint.Name, err) return nil } - client := newIndexerClient(index, name, rpcClient, indexer.indexerCache, archive, priority) + client := newIndexerClient(index, endpoint.Name, rpcClient, indexer.indexerCache, endpoint.Archive, endpoint.Priority, endpoint.SkipValidators) indexer.indexerClients = append(indexer.indexerClients, client) return client } diff --git a/services/beaconservice.go b/services/beaconservice.go index 0761fc35..d258a249 100644 --- a/services/beaconservice.go +++ b/services/beaconservice.go @@ -45,7 +45,7 @@ func StartBeaconService() error { } for idx, endpoint := range utils.Config.BeaconApi.Endpoints { - indexer.AddClient(uint8(idx), endpoint.Name, endpoint.Url, endpoint.Archive, endpoint.Priority, endpoint.Headers) + indexer.AddClient(uint8(idx), &endpoint) } validatorNames := &ValidatorNames{} diff --git a/types/config.go b/types/config.go index ac741742..817b3f2e 100644 --- a/types/config.go +++ b/types/config.go @@ -93,11 +93,12 @@ type Config struct { } type EndpointConfig struct { - Url string `yaml:"url"` - Name string `yaml:"name"` - Archive bool `yaml:"archive"` - Priority int `yaml:"priority"` - Headers map[string]string `yaml:"headers"` + Url string `yaml:"url"` + Name string `yaml:"name"` + Archive bool `yaml:"archive"` + SkipValidators bool `yaml:"skipValidators"` + Priority int `yaml:"priority"` + Headers map[string]string `yaml:"headers"` } type SqliteDatabaseConfig struct {