Skip to content

Commit

Permalink
feat: update to v2 events
Browse files Browse the repository at this point in the history
  • Loading branch information
Savid committed Aug 22, 2023
1 parent 6aff1fc commit 7d676c2
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 172 deletions.
12 changes: 6 additions & 6 deletions pkg/mimicry/p2p/execution/event_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ func (p *Peer) handleTransaction(ctx context.Context, eventTime time.Time, event

decoratedEvent := &xatu.DecoratedEvent{
Event: &xatu.Event{
Name: xatu.Event_MEMPOOL_TRANSACTION,
Name: xatu.Event_MEMPOOL_TRANSACTION_V2,
DateTime: timestamppb.New(now),
},
Meta: &xatu.Meta{
Client: meta,
},
Data: &xatu.DecoratedEvent_MempoolTransaction{
MempoolTransaction: fmt.Sprintf("0x%x", tx),
Data: &xatu.DecoratedEvent_MempoolTransactionV2{
MempoolTransactionV2: fmt.Sprintf("0x%x", tx),
},
}

additionalData, err := p.getTransactionData(ctx, event, meta, now)
if err != nil {
p.log.WithError(err).Error("Failed to get extra transaction data")
} else {
decoratedEvent.Meta.Client.AdditionalData = &xatu.ClientMeta_MempoolTransaction{
MempoolTransaction: additionalData,
decoratedEvent.Meta.Client.AdditionalData = &xatu.ClientMeta_MempoolTransactionV2{
MempoolTransactionV2: additionalData,
}
}

return decoratedEvent, nil
}

func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction, meta *xatu.ClientMeta, eventTime time.Time) (*xatu.ClientMeta_AdditionalMempoolTransactionData, error) {
func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction, meta *xatu.ClientMeta, eventTime time.Time) (*xatu.ClientMeta_AdditionalMempoolTransactionV2Data, error) {
var to string
if event.To() != nil {
to = event.To().String()
Expand Down
Loading

0 comments on commit 7d676c2

Please sign in to comment.