diff --git a/pkg/server/service/event-ingester/event/beacon/eth/v1/beacon_committee.go b/pkg/server/service/event-ingester/event/beacon/eth/v1/beacon_committee.go new file mode 100644 index 00000000..8bf916cf --- /dev/null +++ b/pkg/server/service/event-ingester/event/beacon/eth/v1/beacon_committee.go @@ -0,0 +1,42 @@ +package v1 + +import ( + "context" + "errors" + + "github.com/ethpandaops/xatu/pkg/proto/xatu" + "github.com/sirupsen/logrus" +) + +const ( + BeaconCommitteeType = "BEACON_API_ETH_V1_BEACON_COMMITTEE" +) + +type BeaconCommittee struct { + log logrus.FieldLogger + event *xatu.DecoratedEvent +} + +func NewBeaconCommittee(log logrus.FieldLogger, event *xatu.DecoratedEvent) *BeaconCommittee { + return &BeaconCommittee{ + log: log.WithField("event", BeaconCommitteeType), + event: event, + } +} + +func (b *BeaconCommittee) Type() string { + return EventsHeadType +} + +func (b *BeaconCommittee) Validate(_ context.Context) error { + _, ok := b.event.GetData().(*xatu.DecoratedEvent_EthV1BeaconCommittee) + if !ok { + return errors.New("failed to cast event data") + } + + return nil +} + +func (b *BeaconCommittee) Filter(_ context.Context) bool { + return false +} diff --git a/pkg/server/service/event-ingester/event/event.go b/pkg/server/service/event-ingester/event/event.go index f39923d4..19e5d889 100644 --- a/pkg/server/service/event-ingester/event/event.go +++ b/pkg/server/service/event-ingester/event/event.go @@ -28,6 +28,7 @@ const ( TypeBeaconETHV2BeaconBlock Type = v2.BeaconBlockType TypeDebugForkChoice Type = v1.DebugForkChoiceType TypeDebugForkChoiceReorg Type = v1.DebugForkChoiceReorgType + TypeBeaconEthV1BeaconCommittee Type = v1.BeaconCommitteeType ) type Event interface { @@ -64,6 +65,8 @@ func New(eventType Type, log logrus.FieldLogger, event *xatu.DecoratedEvent, cac return v1.NewDebugForkChoice(log, event), nil case TypeDebugForkChoiceReorg: return v1.NewDebugForkChoiceReorg(log, event), nil + case TypeBeaconEthV1BeaconCommittee: + return v1.NewBeaconCommittee(log, event), nil default: return nil, fmt.Errorf("event type %s is unknown", eventType) }