forked from babylonlabs-io/babylon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.go
68 lines (57 loc) · 1.7 KB
/
hooks.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package types
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// combine multiple Checkpointing hooks, all hook functions are run in array sequence
var _ CheckpointingHooks = &MultiCheckpointingHooks{}
type MultiCheckpointingHooks []CheckpointingHooks
func NewMultiCheckpointingHooks(hooks ...CheckpointingHooks) MultiCheckpointingHooks {
return hooks
}
func (h MultiCheckpointingHooks) AfterBlsKeyRegistered(ctx context.Context, valAddr sdk.ValAddress) error {
for i := range h {
if err := h[i].AfterBlsKeyRegistered(ctx, valAddr); err != nil {
return err
}
}
return nil
}
func (h MultiCheckpointingHooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error {
for i := range h {
if err := h[i].AfterRawCheckpointSealed(ctx, epoch); err != nil {
return err
}
}
return nil
}
func (h MultiCheckpointingHooks) AfterRawCheckpointConfirmed(ctx context.Context, epoch uint64) error {
for i := range h {
if err := h[i].AfterRawCheckpointConfirmed(ctx, epoch); err != nil {
return err
}
}
return nil
}
func (h MultiCheckpointingHooks) AfterRawCheckpointForgotten(ctx context.Context, ckpt *RawCheckpoint) error {
for i := range h {
return h[i].AfterRawCheckpointForgotten(ctx, ckpt)
}
return nil
}
func (h MultiCheckpointingHooks) AfterRawCheckpointFinalized(ctx context.Context, epoch uint64) error {
for i := range h {
if err := h[i].AfterRawCheckpointFinalized(ctx, epoch); err != nil {
return err
}
}
return nil
}
func (h MultiCheckpointingHooks) AfterRawCheckpointBlsSigVerified(ctx context.Context, ckpt *RawCheckpoint) error {
for i := range h {
if err := h[i].AfterRawCheckpointBlsSigVerified(ctx, ckpt); err != nil {
return err
}
}
return nil
}