diff --git a/indexer/cache.go b/indexer/cache.go index c56971b0..e54bd567 100644 --- a/indexer/cache.go +++ b/indexer/cache.go @@ -56,6 +56,9 @@ func (cache *indexerCache) startSynchronizer(startEpoch uint64) { cache.cacheMutex.Lock() defer cache.cacheMutex.Unlock() + if cache.indexer.disableSync { + return + } if cache.synchronizer == nil { cache.synchronizer = newSynchronizer(cache.indexer) } diff --git a/indexer/indexer.go b/indexer/indexer.go index ccdd5f8b..f2d610c6 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -21,6 +21,7 @@ type Indexer struct { indexerClients []*IndexerClient writeDb bool + disableSync bool inMemoryEpochs uint16 } @@ -34,6 +35,7 @@ func NewIndexer() (*Indexer, error) { indexerClients: make([]*IndexerClient, 0), writeDb: !utils.Config.Indexer.DisableIndexWriter, + disableSync: utils.Config.Indexer.DisableSynchronizer, inMemoryEpochs: inMemoryEpochs, } indexer.indexerCache = newIndexerCache(indexer) diff --git a/services/beaconservice.go b/services/beaconservice.go index 046b5d52..0761fc35 100644 --- a/services/beaconservice.go +++ b/services/beaconservice.go @@ -288,6 +288,10 @@ func (bs *BeaconService) GetEpochAssignments(epoch uint64) (*rpctypes.EpochAssig } } + if utils.Config.BeaconApi.SkipFinalAssignments { + return nil, nil + } + bs.assignmentsCacheMux.Lock() epochAssignments, found := bs.assignmentsCache.Get(epoch) bs.assignmentsCacheMux.Unlock() diff --git a/types/config.go b/types/config.go index 2d2cb3aa..ac741742 100644 --- a/types/config.go +++ b/types/config.go @@ -51,15 +51,17 @@ type Config struct { Endpoints []EndpointConfig `yaml:"endpoints"` LocalCacheSize int `yaml:"localCacheSize" envconfig:"BEACONAPI_LOCAL_CACHE_SIZE"` + SkipFinalAssignments bool `yaml:"skipFinalAssignments" envconfig:"BEACONAPI_SKIP_FINAL_ASSIGNMENTS"` AssignmentsCacheSize int `yaml:"assignmentsCacheSize" envconfig:"BEACONAPI_ASSIGNMENTS_CACHE_SIZE"` RedisCacheAddr string `yaml:"redisCacheAddr" envconfig:"BEACONAPI_REDIS_CACHE_ADDR"` RedisCachePrefix string `yaml:"redisCachePrefix" envconfig:"BEACONAPI_REDIS_CACHE_PREFIX"` } `yaml:"beaconapi"` Indexer struct { - InMemoryEpochs uint16 `yaml:"inMemoryEpochs" envconfig:"INDEXER_IN_MEMORY_EPOCHS"` - DisableIndexWriter bool `yaml:"disableIndexWriter" envconfig:"INDEXER_DISABLE_INDEX_WRITER"` - SyncEpochCooldown uint `yaml:"syncEpochCooldown" envconfig:"INDEXER_SYNC_EPOCH_COOLDOWN"` + InMemoryEpochs uint16 `yaml:"inMemoryEpochs" envconfig:"INDEXER_IN_MEMORY_EPOCHS"` + DisableIndexWriter bool `yaml:"disableIndexWriter" envconfig:"INDEXER_DISABLE_INDEX_WRITER"` + DisableSynchronizer bool `yaml:"disableSynchronizer" envconfig:"INDEXER_DISABLE_SYNCHRONIZER"` + SyncEpochCooldown uint `yaml:"syncEpochCooldown" envconfig:"INDEXER_SYNC_EPOCH_COOLDOWN"` } `yaml:"indexer"` Database struct {