-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
can_process_message.go
43 lines (36 loc) · 1.23 KB
/
can_process_message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package processor
import (
"context"
"log/slog"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/taikoxyz/taiko-mono/packages/relayer"
)
// canProcessMessage determines whether a message is processable by the relayer.
// there are several conditions which it would not be processable, which include:
// - the event status is New, and the GasLimit is 0, which means only the user who
// sent the message can process it.
// - the event status is not New, which means it is either already processed and succeeded,
// or its processed, failed, and is in Retriable or Failed state, where the user
// should finish manually.
func canProcessMessage(
ctx context.Context,
eventStatus relayer.EventStatus,
messageOwner common.Address,
relayerAddress common.Address,
gasLimit *big.Int,
) bool {
// we can not process, exit early
if eventStatus == relayer.EventStatusNew && gasLimit == nil || gasLimit.Cmp(common.Big0) == 0 {
if messageOwner != relayerAddress {
slog.Info("gasLimit == 0 and owner is not the current relayer key, can not process.")
return false
}
return true
}
if eventStatus == relayer.EventStatusNew {
return true
}
slog.Info("cant process message", "eventStatus", eventStatus.String())
return false
}