mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
83416f31a5
* adding changes to blocks * trying out expiration * adding implementation, have WIP for tests * adding unit tests for cache * fixing bazel complaints * fix linting * adding safe check for unint type * changing approach to safety check * adding cache to bazel to test fixing build * reverting bazel change and adding flag to usage * implementing interface on mock to fix build error * fixing unit tests * fixing unit test * fixing unit tests * fixing linting * fixing more unit tests * fixing produce blinded block tests * Update beacon-chain/cache/registration.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * resolving review comments * fixing cache * Update beacon-chain/cache/registration.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * Update beacon-chain/cache/registration.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * fixing time logic * adding context to trace * fix bazel lint * fixing context dependency * fix linting * Update cmd/beacon-chain/flags/base.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * addressing review comments * fixing deepsource issues * improving the default settings * fixing bazel * removing irrelevant unit test * updating name --------- Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package builder
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/v4/api/client/builder"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/cache"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/db"
|
|
"github.com/prysmaticlabs/prysm/v4/cmd/beacon-chain/flags"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
type Option func(s *Service) error
|
|
|
|
// FlagOptions for builder service flag configurations.
|
|
func FlagOptions(c *cli.Context) ([]Option, error) {
|
|
endpoint := c.String(flags.MevRelayEndpoint.Name)
|
|
var client *builder.Client
|
|
if endpoint != "" {
|
|
var err error
|
|
client, err = builder.NewClient(endpoint)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
opts := []Option{
|
|
WithBuilderClient(client),
|
|
}
|
|
return opts, nil
|
|
}
|
|
|
|
// WithBuilderClient sets the builder client for the beacon chain builder service.
|
|
func WithBuilderClient(client builder.BuilderClient) Option {
|
|
return func(s *Service) error {
|
|
s.cfg.builderClient = client
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithHeadFetcher gets the head info from chain service.
|
|
func WithHeadFetcher(svc blockchain.HeadFetcher) Option {
|
|
return func(s *Service) error {
|
|
s.cfg.headFetcher = svc
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithDatabase for head access.
|
|
func WithDatabase(beaconDB db.HeadAccessDatabase) Option {
|
|
return func(s *Service) error {
|
|
s.cfg.beaconDB = beaconDB
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithRegistrationCache uses a cache for the validator registrations instead of a persistent db.
|
|
func WithRegistrationCache() Option {
|
|
return func(s *Service) error {
|
|
s.registrationCache = cache.NewRegistrationCache()
|
|
return nil
|
|
}
|
|
}
|