feat: add endblocker with valsetupdate type (#15829)

This commit is contained in:
Marko
2023-04-14 09:41:29 +00:00
committed by GitHub
parent 722bea5b40
commit 8d6c23faa4
18 changed files with 200 additions and 73 deletions
+26
View File
@@ -0,0 +1,26 @@
package keeper
import (
"context"
"time"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
// BeginBlocker will persist the current header and validator set as a historical entry
// and prune the oldest entry based on the HistoricalEntries parameter
func (k *Keeper) BeginBlocker(ctx sdk.Context) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
k.TrackHistoricalInfo(ctx)
}
// Called every block, update validator set
func (k *Keeper) EndBlocker(ctx context.Context) ([]abci.ValidatorUpdate, error) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
return k.BlockValidatorUpdates(sdk.UnwrapSDKContext(ctx)), nil
}