Skip to content

Commit

Permalink
added option to disable synchronizer and option to disable fetching o…
Browse files Browse the repository at this point in the history
…ld epoch assignments for block details
  • Loading branch information
pk910 committed Aug 31, 2023
1 parent 0b09f43 commit 1c064dc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions indexer/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Indexer struct {
indexerClients []*IndexerClient

writeDb bool
disableSync bool
inMemoryEpochs uint16
}

Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions services/beaconservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1c064dc

Please sign in to comment.