modified app provider to pass genesis

This commit is contained in:
rigelrozanski 2018-11-13 13:01:18 -05:00
parent 956d351f68
commit ebaa39468a
5 changed files with 34 additions and 10 deletions

View File

@ -39,6 +39,11 @@ func SetMinimumFees(minFees string) func(*BaseApp) {
return func(bap *BaseApp) { bap.SetMinimumFees(fees) }
}
// SetMinimumFees returns an option that sets the minimum fees on the app.
func SetMaximumBlockGas(gas int64) func(*BaseApp) {
return func(bap *BaseApp) { bap.SetMaximumBlockGas(gas) }
}
func (app *BaseApp) SetName(name string) {
if app.sealed {
panic("SetName() on sealed BaseApp")

View File

@ -42,8 +42,10 @@ type GenesisState struct {
GenTxs []json.RawMessage `json:"gentxs"`
}
func NewGenesisState(accounts []GenesisAccount, authData auth.GenesisState, stakeData stake.GenesisState, mintData mint.GenesisState,
distrData distr.GenesisState, govData gov.GenesisState, slashingData slashing.GenesisState) GenesisState {
func NewGenesisState(accounts []GenesisAccount, authData auth.GenesisState,
stakeData stake.GenesisState, mintData mint.GenesisState,
distrData distr.GenesisState, govData gov.GenesisState,
slashingData slashing.GenesisState) GenesisState {
return GenesisState{
Accounts: accounts,
@ -287,7 +289,7 @@ func CollectStdTxs(cdc *codec.Codec, moniker string, genTxsDir string, genDoc tm
func NewDefaultGenesisAccount(addr sdk.AccAddress) GenesisAccount {
accAuth := auth.NewBaseAccountWithAddress(addr)
coins :=sdk.Coins{
coins := sdk.Coins{
{"fooToken", sdk.NewInt(1000)},
{bondDenom, freeFermionsAcc},
}

View File

@ -13,6 +13,7 @@ import (
"github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/node"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
@ -56,16 +57,27 @@ func main() {
}
}
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application {
func newApp(logger log.Logger, db dbm.DB,
traceStore io.Writer, genDocProvider node.GenesisDocProvider) abci.Application {
// get the maximum gas from tendermint genesis parameters
genDoc, err := genDocProvider()
if err != nil {
panic(err)
}
maxBlockGas := genDoc.ConsensusParams.BlockSize.MaxGas
return app.NewGaiaApp(logger, db, traceStore,
baseapp.SetPruning(viper.GetString("pruning")),
baseapp.SetMinimumFees(viper.GetString("minimum_fees")),
baseapp.SetMaximumBlockGas(maxBlockGas),
)
}
func exportAppStateAndTMValidators(
logger log.Logger, db dbm.DB, traceStore io.Writer,
) (json.RawMessage, []tmtypes.GenesisValidator, error) {
logger log.Logger, db dbm.DB, traceStore io.Writer) (
json.RawMessage, []tmtypes.GenesisValidator, error) {
gApp := app.NewGaiaApp(logger, db, traceStore)
return gApp.ExportAppStateAndValidators()
}

View File

@ -9,13 +9,15 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/node"
tmtypes "github.com/tendermint/tendermint/types"
)
type (
// AppCreator is a function that allows us to lazily initialize an
// application using various configurations.
AppCreator func(log.Logger, dbm.DB, io.Writer) abci.Application
AppCreator func(log.Logger, dbm.DB,
io.Writer, node.GenesisDocProvider) abci.Application
// AppExporter is a function that dumps all app state to
// JSON-serializable structure and returns the current validator set.

View File

@ -68,7 +68,9 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error {
return err
}
app := appCreator(ctx.Logger, db, traceWriter)
cfg := ctx.Config
genDocProvider := node.DefaultGenesisDocProviderFunc(cfg)
app := appCreator(ctx.Logger, db, traceWriter, genDocProvider)
svr, err := server.NewServer(addr, "socket", app)
if err != nil {
@ -107,7 +109,8 @@ func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
return nil, err
}
app := appCreator(ctx.Logger, db, traceWriter)
genDocProvider := node.DefaultGenesisDocProviderFunc(cfg)
app := appCreator(ctx.Logger, db, traceWriter, genDocProvider)
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
if err != nil {
@ -120,7 +123,7 @@ func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
pvm.LoadOrGenFilePV(cfg.PrivValidatorFile()),
nodeKey,
proxy.NewLocalClientCreator(app),
node.DefaultGenesisDocProviderFunc(cfg),
genDocProvider,
node.DefaultDBProvider,
node.DefaultMetricsProvider(cfg.Instrumentation),
ctx.Logger.With("module", "node"),