Skip to content

Commit

Permalink
Add basic constructor
Browse files Browse the repository at this point in the history
Signed-off-by: litt3 <[email protected]>
  • Loading branch information
litt3 committed Jan 31, 2025
1 parent 62f139c commit f087501
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
8 changes: 8 additions & 0 deletions api/clients/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ func (rc *DistributedPayloadRetrieverConfig) checkAndSetDefaults() error {
return err
}

if rc.BlsOperatorStateRetrieverAddr == "" {
return fmt.Errorf("BlsOperatorStateRetrieverAddr is required")
}

if rc.EigenDAServiceManagerAddr == "" {
return fmt.Errorf("EigenDAServiceManagerAddr is required")
}

defaultConfig := GetDefaultDistributedPayloadRetrieverConfig()
if rc.RetrievalTimeout == 0 {
rc.RetrievalTimeout = defaultConfig.RetrievalTimeout
Expand Down
30 changes: 27 additions & 3 deletions api/clients/v2/distributed_payload_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ import (
// This struct is goroutine safe.
type DistributedPayloadRetriever struct {
logger logging.Logger
config DistributedPayloadRetrieverConfig
config DistributedPayloadRetrieverConfig
codec codecs.BlobCodec
retrievalClient RetrievalClient
g1Srs []bn254.G1Affine
}

var _ PayloadRetriever = &DistributedPayloadRetriever{}

// TODO: add basic constructor

// BuildDistributedPayloadRetriever builds a DistributedPayloadRetriever from config structs.
func BuildDistributedPayloadRetriever(
logger logging.Logger,
Expand All @@ -42,6 +40,10 @@ func BuildDistributedPayloadRetriever(
thegraphConfig thegraph.Config,
kzgConfig kzg.KzgConfig,
) (*DistributedPayloadRetriever, error) {
err := distributedPayloadRetrieverConfig.checkAndSetDefaults()
if err != nil {
return nil, fmt.Errorf("check and set config defaults: %w", err)
}

ethClient, err := geth.NewClient(ethConfig, gethcommon.Address{}, 0, logger)
if err != nil {
Expand Down Expand Up @@ -88,6 +90,28 @@ func BuildDistributedPayloadRetriever(
}, nil
}

// NewDistributedPayloadRetriever creates a new DistributedPayloadRetriever from already constructed objects
func NewDistributedPayloadRetriever(
logger logging.Logger,
config DistributedPayloadRetrieverConfig,
codec codecs.BlobCodec,
retrievalClient RetrievalClient,
g1Srs []bn254.G1Affine,
) (*DistributedPayloadRetriever, error) {
err := config.checkAndSetDefaults()
if err != nil {
return nil, fmt.Errorf("check and set config defaults: %w", err)
}

return &DistributedPayloadRetriever{
logger: logger,
config: config,
codec: codec,
retrievalClient: retrievalClient,
g1Srs: g1Srs,
}, nil
}

// GetPayload iteratively attempts to retrieve a given blob from the quorums listed in the EigenDACert.
//
// If the blob is successfully retrieved, then the blob is verified. If the verification succeeds, the blob is decoded
Expand Down

0 comments on commit f087501

Please sign in to comment.