Skip to content

Commit

Permalink
Merge pull request #376 from wukongcheng/silei/release0.5
Browse files Browse the repository at this point in the history
update software upgrade example
  • Loading branch information
wukongcheng authored Oct 11, 2018
2 parents 89e5516 + b36d08a commit e2f7567
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
27 changes: 14 additions & 13 deletions examples/irishub-bugfix-2/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ import (
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/irisnet/irishub/modules/gov"
"github.com/cosmos/cosmos-sdk/x/ibc"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
ibcbugfix "github.com/irisnet/irishub/examples/irishub-bugfix-2/ibc"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/upgrade"

"errors"
"fmt"
"github.com/cosmos/cosmos-sdk/server"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/iparam"
"github.com/irisnet/irishub/modules/upgrade/params"
"github.com/spf13/viper"
bc "github.com/tendermint/tendermint/blockchain"
tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/node"
sm "github.com/tendermint/tendermint/state"
bc "github.com/tendermint/tendermint/blockchain"
"strings"
"github.com/irisnet/irishub/modules/iparam"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/upgrade/params"
)

const (
Expand Down Expand Up @@ -160,15 +160,16 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio

upgrade.RegisterModuleList(app.Router())
iparam.SetParamReadWriter(app.paramsKeeper.Setter(),
&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,
&upgradeparams.CurrentUpgradeProposalIdParameter,
&upgradeparams.ProposalAcceptHeightParameter)
&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,
&upgradeparams.CurrentUpgradeProposalIdParameter,
&upgradeparams.ProposalAcceptHeightParameter,
&upgradeparams.SwitchPeriodParameter)

iparam.RegisterGovParamMapping(&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,)
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter)

return app
}
Expand Down Expand Up @@ -265,7 +266,7 @@ func (app *IrisApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
// load the address to pubkey map
slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.StakeData)

upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router())
upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router(), genesisState.UpgradeData)

return abci.ResponseInitChain{
Validators: validators,
Expand Down
14 changes: 10 additions & 4 deletions examples/irishub-bugfix-2/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ import (
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/stake"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/upgrade"
"github.com/irisnet/irishub/types"
"time"
)

// State to Unmarshal
type GenesisState struct {
Accounts []GenesisAccount `json:"accounts"`
StakeData stake.GenesisState `json:"stake"`
Accounts []GenesisAccount `json:"accounts"`
StakeData stake.GenesisState `json:"stake"`
GovData gov.GenesisState `json:"gov"`
UpgradeData upgrade.GenesisState `json:"upgrade"`
}

// GenesisAccount doesn't need pubkey or sequence
Expand Down Expand Up @@ -194,8 +198,10 @@ func IrisAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState

// create the final app state
genesisState = GenesisState{
Accounts: genaccs,
StakeData: stakeData,
Accounts: genaccs,
StakeData: stakeData,
GovData: gov.DefaultGenesisState(),
UpgradeData: upgrade.DefaultGenesisState(),
}
return
}
Expand Down
25 changes: 13 additions & 12 deletions examples/irishub1/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ import (
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/irisnet/irishub/modules/gov"
"github.com/cosmos/cosmos-sdk/x/ibc"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
bam "github.com/irisnet/irishub/baseapp"
ibc1 "github.com/irisnet/irishub/examples/irishub1/ibc"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/iparam"
"github.com/irisnet/irishub/modules/upgrade"
"github.com/irisnet/irishub/modules/upgrade/params"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
bc "github.com/tendermint/tendermint/blockchain"
Expand All @@ -31,9 +34,6 @@ import (
sm "github.com/tendermint/tendermint/state"
tmtypes "github.com/tendermint/tendermint/types"
"strings"
"github.com/irisnet/irishub/modules/iparam"
"github.com/irisnet/irishub/modules/gov/params"
"github.com/irisnet/irishub/modules/upgrade/params"
)

const (
Expand Down Expand Up @@ -157,15 +157,16 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio

upgrade.RegisterModuleList(app.Router())
iparam.SetParamReadWriter(app.paramsKeeper.Setter(),
&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,
&upgradeparams.CurrentUpgradeProposalIdParameter,
&upgradeparams.ProposalAcceptHeightParameter)
&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,
&upgradeparams.CurrentUpgradeProposalIdParameter,
&upgradeparams.ProposalAcceptHeightParameter,
&upgradeparams.SwitchPeriodParameter)

iparam.RegisterGovParamMapping(&govparams.DepositProcedureParameter,
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter,)
&govparams.VotingProcedureParameter,
&govparams.TallyingProcedureParameter)

return app
}
Expand Down Expand Up @@ -263,7 +264,7 @@ func (app *IrisApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
// load the address to pubkey map
slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.StakeData)

upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router())
upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router(), genesisState.UpgradeData)

return abci.ResponseInitChain{
Validators: validators,
Expand Down
14 changes: 10 additions & 4 deletions examples/irishub1/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ import (
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/stake"
"github.com/irisnet/irishub/modules/gov"
"github.com/irisnet/irishub/modules/upgrade"
"github.com/irisnet/irishub/types"
"time"
)

// State to Unmarshal
type GenesisState struct {
Accounts []GenesisAccount `json:"accounts"`
StakeData stake.GenesisState `json:"stake"`
Accounts []GenesisAccount `json:"accounts"`
StakeData stake.GenesisState `json:"stake"`
GovData gov.GenesisState `json:"gov"`
UpgradeData upgrade.GenesisState `json:"upgrade"`
}

// GenesisAccount doesn't need pubkey or sequence
Expand Down Expand Up @@ -194,8 +198,10 @@ func IrisAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState

// create the final app state
genesisState = GenesisState{
Accounts: genaccs,
StakeData: stakeData,
Accounts: genaccs,
StakeData: stakeData,
GovData: gov.DefaultGenesisState(),
UpgradeData: upgrade.DefaultGenesisState(),
}
return
}
Expand Down

0 comments on commit e2f7567

Please sign in to comment.