Documentation ¶
Index ¶
- Variables
- func AddGenesisAccountCmd(ctx *app.Context, cdc *codec.Codec) *cobra.Command
- func AddGenesisShardCmd(ctx *app.Context, cdc *codec.Codec) *cobra.Command
- func AddGenesisValidatorCmd(ctx *app.Context, cdc *codec.Codec) *cobra.Command
- func AddServerCommands(ctx *app.Context, cdc *amino.Codec, rootCmd *cobra.Command, ...)
- func CopyFile(src, dst string) error
- func GetVersion() string
- func InitWithConfig(cdc *amino.Codec, appInit app.AppInit, c *cfg.Config, initConfig InitConfig) (chainID string, nodeID string, appMessage json.RawMessage, ...)
- func ParseAccAddress(addr string) types.AccAddress
- func ParseCoin(denom, amount string) (types.Coin, error)
- func StartInProcess(ctx *app.Context, appCreator app.AppCreator, cdc *codec.Codec) (*node.Node, error)
- type GenesisTx
- type InitConfig
- type ValidatorAccount
Constants ¶
This section is empty.
Variables ¶
View Source
var ( FlagName = "name" FlagClientHome = "home-client" FlagOWK = "owk" )
View Source
var ( FlagOverwrite = "overwrite" FlagWithTxs = "with-txs" FlagIP = "ip" FlagChainID = "chain_id" FlagStateDB = "statedb" //FlagDBName = "dbname" FlagWithValidator = "validator_key" FlagCoinName = "denom" )
Functions ¶
func AddGenesisAccountCmd ¶
func AddGenesisShardCmd ¶
func AddGenesisValidatorCmd ¶
func AddServerCommands ¶
func AddServerCommands( ctx *app.Context, cdc *amino.Codec, rootCmd *cobra.Command, appInit app.AppInit, appCreator app.AppCreator, appExport app.AppExporter, )
func InitWithConfig ¶
func InitWithConfig(cdc *amino.Codec, appInit app.AppInit, c *cfg.Config, initConfig InitConfig) ( chainID string, nodeID string, appMessage json.RawMessage, pubKey crypto.PubKey, err error)
func InitWithConfig(cdc *amino.Codec, appInit app.AppInit, c *cfg.Config, initConfig InitConfig)(
chainID string, nodeID string, appMessage json.RawMessage, pubKey string, err error) { var validatorKey secp256k1.PrivKeySecp256k1 var privStr string nodeKey, err := node.LoadNodeKey(c.NodeKeyFile()) privBz := viper.GetString(FlagWithValidator) if len(privBz) > 0 { //1.match length priByt := []byte(privBz) length := len(priByt) if length != 44 { panic(errors.New(fmt.Sprintf("length of validator key does not match, expected %d, got %d",44 ,length))) } //2.regex match rule := `=$` reg := regexp.MustCompile(rule) if !reg.MatchString(privBz) { panic(errors.New("the end of the validator key string should be an equal sign")) } //3.match base64 encoding _,err := base64.StdEncoding.DecodeString(privBz) if err != nil { panic(err) } privStr = fmt.Sprintf(`{"type":"%s","value":"%s"}`, secp256k1.PrivKeyAminoName, privBz) err = cdc.UnmarshalJSON([]byte(privStr), &validatorKey) if err != nil { panic(err) } }else { panic(errors.New("validator key can not be empty")) } pv := validator.GenFilePV( c.PrivValidatorKeyFile(), c.PrivValidatorStateFile(), validatorKey, ) nodeKey, err = node.GenNodeKeyByPrivKey(c.NodeKeyFile(), pv.Key.PrivKey) if err != nil { panic(err) } nodeID = string(nodeKey.ID()) chainID = initConfig.ChainID genFile := c.GenesisFile() if !initConfig.Overwrite && cmn.FileExists(genFile) { err = fmt.Errorf("genesis.json file already exists: %v", genFile) return } validator := appInit.GetValidator(nodeKey.PubKey(), viper.GetString(FlagName)) validators := []tmtypes.GenesisValidator{validator} appState, err := appInit.AppGenState(validators) if err != nil { return } err = writeGenesisFile(cdc, genFile, initConfig.ChainID, validators, appState, initConfig.GenesisTime) if err != nil { return } return }
func ParseAccAddress ¶
func ParseAccAddress(addr string) types.AccAddress
Types ¶
type GenesisTx ¶
type GenesisTx struct { NodeID string `json:"node_id"` IP string `json:"ip"` Validator tmtypes.GenesisValidator `json:"validator"` AppGenTx json.RawMessage `json:"app_gen_tx"` }
type InitConfig ¶
type ValidatorAccount ¶
Click to show internal directories.
Click to hide internal directories.