Skip to content

Commit

Permalink
Feat(cannon): Validators chunk size (#330)
Browse files Browse the repository at this point in the history
feat(cannon): Validators chunk size
  • Loading branch information
samcm authored Jun 11, 2024
1 parent 734e643 commit 7541a3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ GeoLite2-City.mmdb
__debug_bin*
.vscode/launch.json
sage.yaml
.goreleaser.yaml.new
.goreleaser.yaml.new
.aider*
12 changes: 9 additions & 3 deletions pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const (
)

type BeaconValidatorsDeriverConfig struct {
Enabled bool `yaml:"enabled" default:"true"`
Enabled bool `yaml:"enabled" default:"true"`
ChunkSize int `yaml:"chunkSize" default:"100"`
}

type BeaconValidatorsDeriver struct {
Expand Down Expand Up @@ -70,6 +71,11 @@ func (b *BeaconValidatorsDeriver) OnEventsDerived(ctx context.Context, fn func(c
}

func (b *BeaconValidatorsDeriver) Start(ctx context.Context) error {
b.log.WithFields(logrus.Fields{
"chunk_size": b.cfg.ChunkSize,
"enabled": b.cfg.Enabled,
}).Info("Starting BeaconValidatorsDeriver")

if !b.cfg.Enabled {
b.log.Info("Validator states deriver disabled")

Expand Down Expand Up @@ -240,8 +246,8 @@ func (b *BeaconValidatorsDeriver) processEpoch(ctx context.Context, epoch phase0

validatorsMap := validatorsResponse.Data

// Chunk the validators per 1000
chunkSize := 1000
// Chunk the validators per the configured chunk size
chunkSize := b.cfg.ChunkSize

var validatorChunks [][]*apiv1.Validator

Expand Down

0 comments on commit 7541a3b

Please sign in to comment.