(ctx *cli.Context, txpoolSvr *proc.TXPoolServer)
| 299 | } |
| 300 | |
| 301 | func initP2PNode(ctx *cli.Context, txpoolSvr *proc.TXPoolServer) (*p2pserver.P2PServer, *actor.PID, error) { |
| 302 | if config.DefConfig.Genesis.ConsensusType == config.CONSENSUS_TYPE_SOLO { |
| 303 | return nil, nil, nil |
| 304 | } |
| 305 | p2p := p2pserver.NewServer() |
| 306 | |
| 307 | p2pActor := p2pactor.NewP2PActor(p2p) |
| 308 | p2pPID, err := p2pActor.Start() |
| 309 | if err != nil { |
| 310 | return nil, nil, fmt.Errorf("p2pActor init error %s", err) |
| 311 | } |
| 312 | p2p.SetPID(p2pPID) |
| 313 | err = p2p.Start() |
| 314 | if err != nil { |
| 315 | return nil, nil, fmt.Errorf("p2p service start error %s", err) |
| 316 | } |
| 317 | netreqactor.SetTxnPoolPid(txpoolSvr.GetPID(tc.TxActor)) |
| 318 | txpoolSvr.RegisterActor(tc.NetActor, p2pPID) |
| 319 | hserver.SetNetServerPID(p2pPID) |
| 320 | p2p.WaitForPeersStart() |
| 321 | log.Infof("P2P init success") |
| 322 | return p2p, p2pPID, nil |
| 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 { |
no test coverage detected