MCPcopy Create free account
hub / github.com/DNAProject/DNA / initP2PNode

Function initP2PNode

main.go:301–323  ·  view source on GitHub ↗
(ctx *cli.Context, txpoolSvr *proc.TXPoolServer)

Source from the content-addressed store, hash-verified

299}
300
301func 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
325func initConsensus(ctx *cli.Context, p2pPid *actor.PID, txpoolSvr *proc.TXPoolServer, acc *account.Account) (consensus.ConsensusService, error) {
326 if !config.DefConfig.Consensus.EnableConsensus {

Callers 1

startDNAFunction · 0.85

Calls 9

StartMethod · 0.95
StartMethod · 0.95
NewServerFunction · 0.92
ErrorfMethod · 0.80
RegisterActorMethod · 0.80
WaitForPeersStartMethod · 0.80
InfofMethod · 0.80
GetPIDMethod · 0.65
SetPIDMethod · 0.45

Tested by

no test coverage detected