Skip to content

Commit

Permalink
feat(event): add BeaconBlobSidecar type
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Oct 10, 2023
1 parent 8a61ca1 commit f00405f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package v1

import (
"context"
"errors"

"github.com/ethpandaops/xatu/pkg/proto/xatu"
"github.com/sirupsen/logrus"
)

const (
BeaconBlobSidecarType = "BEACON_API_ETH_V1_BEACON_BLOB_SIDECAR"
)

type BeaconBlobSidecar struct {
log logrus.FieldLogger
event *xatu.DecoratedEvent
}

func NewBeaconBlobSidecar(log logrus.FieldLogger, event *xatu.DecoratedEvent) *BeaconBlobSidecar {
return &BeaconBlobSidecar{
log: log.WithField("event", BeaconBlobSidecarType),
event: event,
}
}

func (b *BeaconBlobSidecar) Type() string {
return BeaconBlobSidecarType
}

func (b *BeaconBlobSidecar) Validate(_ context.Context) error {
_, ok := b.event.GetData().(*xatu.DecoratedEvent_EthV1BeaconBlockBlobSidecar)
if !ok {
return errors.New("failed to cast event data")
}

return nil
}

func (b *BeaconBlobSidecar) Filter(_ context.Context) bool {
return false
}
3 changes: 3 additions & 0 deletions pkg/server/service/event-ingester/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
TypeBeaconEthV2BeaconWithdrawal Type = v2.BeaconBlockWithdrawalType
TypeBlockprintBlockClassification Type = blockprint.BlockClassificationType
TypeBeaconETHV1EventsBlobSidecar Type = v1.EventsBlobSidecarType
TypeBeaconETHV1BeaconBlobSidecar Type = v1.BeaconBlobSidecarType
)

type Event interface {
Expand Down Expand Up @@ -132,6 +133,8 @@ func New(eventType Type, log logrus.FieldLogger, event *xatu.DecoratedEvent, cac
return blockprint.NewBlockClassification(log, event), nil
case TypeBeaconETHV1EventsBlobSidecar:
return v1.NewEventsBlobSidecar(log, event), nil
case TypeBeaconETHV1BeaconBlobSidecar:
return v1.NewBeaconBlobSidecar(log, event), nil

default:
return nil, fmt.Errorf("event type %s is unknown", eventType)
Expand Down

0 comments on commit f00405f

Please sign in to comment.