Skip to content

Commit

Permalink
Swap uint64s to wrapperspb
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Jul 20, 2023
1 parent d5b172c commit fec5aea
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 31 deletions.
61 changes: 37 additions & 24 deletions pkg/proto/eth/v1/committee.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions pkg/proto/eth/v1/committee.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ syntax = "proto3";

package xatu.eth.v1;

import "google/protobuf/wrappers.proto";

option go_package = "github.com/ethpandaops/xatu/pkg/proto/eth/v1";

// Committee is a set of validators that are assigned to a commitee for a given slot.
message Committee {
uint64 index = 1;
uint64 slot = 2;
repeated uint64 validators = 3;
google.protobuf.UInt64Value index = 1;
google.protobuf.UInt64Value slot = 2;
repeated google.protobuf.UInt64Value validators = 3;
}
9 changes: 5 additions & 4 deletions pkg/sentry/event/beacon/eth/v1/beacon_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
ttlcache "github.com/savid/ttlcache/v3"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

type BeaconCommittee struct {
Expand Down Expand Up @@ -44,9 +45,9 @@ func NewBeaconCommittee(log logrus.FieldLogger, event *v1.BeaconCommittee, epoch
}

func (e *BeaconCommittee) Decorate(ctx context.Context) (*xatu.DecoratedEvent, error) {
validators := make([]uint64, len(e.event.Validators))
validators := make([]*wrapperspb.UInt64Value, len(e.event.Validators))
for i := range e.event.Validators {
validators[i] = uint64(e.event.Validators[i])
validators[i] = &wrapperspb.UInt64Value{Value: uint64(e.event.Validators[i])}
}

decoratedEvent := &xatu.DecoratedEvent{
Expand All @@ -60,8 +61,8 @@ func (e *BeaconCommittee) Decorate(ctx context.Context) (*xatu.DecoratedEvent, e
},
Data: &xatu.DecoratedEvent_EthV1BeaconCommittee{
EthV1BeaconCommittee: &xatuethv1.Committee{
Slot: uint64(e.event.Slot),
Index: uint64(e.event.Index),
Slot: &wrapperspb.UInt64Value{Value: uint64(e.event.Slot)},
Index: &wrapperspb.UInt64Value{Value: uint64(e.event.Index)},
Validators: validators,
},
},
Expand Down

0 comments on commit fec5aea

Please sign in to comment.