forked from babylonchain/babylon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abci.go
28 lines (23 loc) · 774 Bytes
/
abci.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
package checkpointing
import (
"context"
"fmt"
"time"
"github.com/babylonchain/babylon/x/checkpointing/types"
"github.com/babylonchain/babylon/x/checkpointing/keeper"
"github.com/cosmos/cosmos-sdk/telemetry"
)
// BeginBlocker is called at the beginning of every block.
// Upon each BeginBlock, if reaching the first block after the epoch begins
// then we store the current validator set with BLS keys
func BeginBlocker(ctx context.Context, k keeper.Keeper) error {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
epoch := k.GetEpoch(ctx)
if epoch.IsFirstBlock(ctx) {
err := k.InitValidatorBLSSet(ctx)
if err != nil {
panic(fmt.Errorf("failed to store validator BLS set: %w", err))
}
}
return nil
}