| 323 | } |
| 324 | |
| 325 | func initConsensus(ctx *cli.Context, p2pPid *actor.PID, txpoolSvr *proc.TXPoolServer, acc *account.Account) (consensus.ConsensusService, error) { |
| 326 | if !config.DefConfig.Consensus.EnableConsensus { |
| 327 | return nil, nil |
| 328 | } |
| 329 | pool := txpoolSvr.GetPID(tc.TxPoolActor) |
| 330 | |
| 331 | consensusType := strings.ToLower(config.DefConfig.Genesis.ConsensusType) |
| 332 | consensusService, err := consensus.NewConsensusService(consensusType, acc, pool, nil, p2pPid) |
| 333 | if err != nil { |
| 334 | return nil, fmt.Errorf("NewConsensusService %s error: %s", consensusType, err) |
| 335 | } |
| 336 | consensusService.Start() |
| 337 | |
| 338 | netreqactor.SetConsensusPid(consensusService.GetPID()) |
| 339 | hserver.SetConsensusPid(consensusService.GetPID()) |
| 340 | |
| 341 | log.Infof("Consensus init success") |
| 342 | return consensusService, nil |
| 343 | } |
| 344 | |
| 345 | func initRpc(ctx *cli.Context) error { |
| 346 | if !config.DefConfig.Rpc.EnableHttpJsonRpc { |