Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R4R] upgrade logic for splitting validator address #535

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/fee_distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ import (
"github.com/binance-chain/node/common/fees"
"github.com/binance-chain/node/common/log"
"github.com/binance-chain/node/common/types"
"github.com/binance-chain/node/common/upgrade"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/stake"
)

func NewValAddrCache(stakeKeeper stake.Keeper) *ValAddrCache {
return &ValAddrCache{
cache := &ValAddrCache{
cache: make(map[string]sdk.AccAddress),
stakeKeeper: stakeKeeper,
}

upgrade.Mgr.RegisterBeginBlocker(sdk.UpgradeSeparateValAddrName, func(ctx sdk.Context) {
cache.ClearCache()
})
return cache
}

type ValAddrCache struct {
Expand Down
20 changes: 2 additions & 18 deletions common/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,10 @@ var Mgr = sdk.UpgradeMgr
const FixOrderSeqInPriceLevelName = "fixOrderSeqInPriceLevel"
const FixDropFilledOrderSeqName = "fixDropFilledOrderSeq"

func Upgrade(name string, before func(), in func(), after func()) {
if sdk.IsUpgradeHeight(name) {
if in != nil {
in()
}
} else if sdk.IsUpgrade(name) {
if after != nil {
after()
}
} else {
if before != nil {
before()
}
}
}

func FixOrderSeqInPriceLevel(before func(), in func(), after func()) {
Upgrade(FixOrderSeqInPriceLevelName, before, in, after)
sdk.Upgrade(FixOrderSeqInPriceLevelName, before, in, after)
}

func FixDropFilledOrderSeq(before func(), after func()) {
Upgrade(FixDropFilledOrderSeqName, before, nil, after)
sdk.Upgrade(FixDropFilledOrderSeqName, before, nil, after)
}