(ctx *cli.Context)
| 33 | ) |
| 34 | |
| 35 | func SetBlockchainConfig(ctx *cli.Context) (*config.BlockchainConfig, error) { |
| 36 | cfg := config.DefConfig |
| 37 | err := setGenesis(ctx, cfg) |
| 38 | if err != nil { |
| 39 | return nil, fmt.Errorf("setGenesis error:%s", err) |
| 40 | } |
| 41 | setCommonConfig(ctx, cfg.Common) |
| 42 | setConsensusConfig(ctx, cfg.Consensus) |
| 43 | setP2PNodeConfig(ctx, cfg.P2PNode) |
| 44 | setRpcConfig(ctx, cfg.Rpc) |
| 45 | setRestfulConfig(ctx, cfg.Restful) |
| 46 | setWebSocketConfig(ctx, cfg.Ws) |
| 47 | if cfg.Genesis.ConsensusType == config.CONSENSUS_TYPE_SOLO { |
| 48 | cfg.Ws.EnableHttpWs = true |
| 49 | cfg.Restful.EnableHttpRestful = true |
| 50 | cfg.Consensus.EnableConsensus = true |
| 51 | cfg.P2PNode.NetworkId = config.NETWORK_ID_SOLO_NET |
| 52 | cfg.P2PNode.NetworkName = config.GetNetworkName(cfg.P2PNode.NetworkId) |
| 53 | cfg.P2PNode.NetworkMagic = config.GetNetworkMagic(cfg.P2PNode.NetworkId) |
| 54 | cfg.Common.GasPrice = 0 |
| 55 | } |
| 56 | return cfg, nil |
| 57 | } |
| 58 | |
| 59 | func setGenesis(ctx *cli.Context, cfg *config.BlockchainConfig) error { |
| 60 | if ctx.Bool(utils.GetFlagName(utils.EnableTestModeFlag)) { |
no test coverage detected