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

Function initConsensus

main.go:325–343  ·  view source on GitHub ↗
(ctx *cli.Context, p2pPid *actor.PID, txpoolSvr *proc.TXPoolServer, acc *account.Account)

Source from the content-addressed store, hash-verified

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 {
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
345func initRpc(ctx *cli.Context) error {
346 if !config.DefConfig.Rpc.EnableHttpJsonRpc {

Callers 1

startDNAFunction · 0.85

Calls 5

GetPIDMethod · 0.95
StartMethod · 0.95
NewConsensusServiceFunction · 0.92
ErrorfMethod · 0.80
InfofMethod · 0.80

Tested by

no test coverage detected