Skip to content

Commit

Permalink
Update contract_transmitter.go for MaxLogsKept
Browse files Browse the repository at this point in the history
  • Loading branch information
reductionista committed Sep 26, 2024
1 parent 26cd0b3 commit badaefb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/services/relay/evm/contract_transmitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func WithRetention(retention time.Duration) OCRTransmitterOption {
}
}

func WithMaxLogsKept(maxLogsKept uint64) OCRTransmitterOption {
return func(ct *contractTransmitter) {
ct.maxLogsKept = maxLogsKept
}
}

func WithReportToEthMetadata(reportToEvmTxMeta ReportToEthMetadata) OCRTransmitterOption {
return func(ct *contractTransmitter) {
if reportToEvmTxMeta != nil {
Expand All @@ -74,6 +80,7 @@ type contractTransmitter struct {
reportToEvmTxMeta ReportToEthMetadata
excludeSigs bool
retention time.Duration
maxLogsKept uint64
}

func transmitterFilterName(addr common.Address) string {
Expand Down Expand Up @@ -106,15 +113,14 @@ func NewOCRContractTransmitter(
reportToEvmTxMeta: reportToEvmTxMetaNoop,
excludeSigs: false,
retention: 0,
maxLogsKept: 0,
}

for _, opt := range opts {
opt(newContractTransmitter)
}

// TODO It would be better to keep MaxLogsKept = 1 for the OCR contract transmitter instead of Retention. We are always interested only in the latest log.
// Although MaxLogsKept is present in the Filter struct, it is not supported by LogPoller yet.
err := lp.RegisterFilter(ctx, logpoller.Filter{Name: transmitterFilterName(address), EventSigs: []common.Hash{transmitted.ID}, Addresses: []common.Address{address}, Retention: newContractTransmitter.retention})
err := lp.RegisterFilter(ctx, logpoller.Filter{Name: transmitterFilterName(address), EventSigs: []common.Hash{transmitted.ID}, Addresses: []common.Address{address}, Retention: newContractTransmitter.retention, MaxLogsKept: newContractTransmitter.maxLogsKept})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit badaefb

Please sign in to comment.