forked from lesnikutsa/babylon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabci.go
31 lines (25 loc) · 997 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
29
30
31
package finality
import (
"context"
"time"
"github.com/babylonchain/babylon/x/finality/keeper"
"github.com/babylonchain/babylon/x/finality/types"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/telemetry"
)
func BeginBlocker(ctx context.Context, k keeper.Keeper) error {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
return nil
}
func EndBlocker(ctx context.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, error) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
// if the BTC staking protocol is activated, i.e., there exists a height where a finality provider
// has voting power, start indexing and tallying blocks
if _, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx); err == nil {
// index the current block
k.IndexBlock(ctx)
// tally all non-finalised blocks
k.TallyBlocks(ctx)
}
return []abci.ValidatorUpdate{}, nil
}