forked from klimovich-x/DeBankChain
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tracer.go
36 lines (28 loc) · 1 KB
/
tracer.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
package op_e2e
import (
"context"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/ethereum-optimism/optimism/op-node/node"
"github.com/ethereum-optimism/optimism/op-service/eth"
)
type FnTracer struct {
OnNewL1HeadFn func(ctx context.Context, sig eth.L1BlockRef)
OnUnsafeL2PayloadFn func(ctx context.Context, from peer.ID, payload *eth.ExecutionPayloadEnvelope)
OnPublishL2PayloadFn func(ctx context.Context, payload *eth.ExecutionPayloadEnvelope)
}
func (n *FnTracer) OnNewL1Head(ctx context.Context, sig eth.L1BlockRef) {
if n.OnNewL1HeadFn != nil {
n.OnNewL1HeadFn(ctx, sig)
}
}
func (n *FnTracer) OnUnsafeL2Payload(ctx context.Context, from peer.ID, payload *eth.ExecutionPayloadEnvelope) {
if n.OnUnsafeL2PayloadFn != nil {
n.OnUnsafeL2PayloadFn(ctx, from, payload)
}
}
func (n *FnTracer) OnPublishL2Payload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) {
if n.OnPublishL2PayloadFn != nil {
n.OnPublishL2PayloadFn(ctx, payload)
}
}
var _ node.Tracer = (*FnTracer)(nil)