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

Function NewDbftService

consensus/dbft/dbft_service.go:63–97  ·  view source on GitHub ↗
(bkAccount *account.Account, txpool, p2p *actor.PID)

Source from the content-addressed store, hash-verified

61}
62
63func NewDbftService(bkAccount *account.Account, txpool, p2p *actor.PID) (*DbftService, error) {
64 service := &DbftService{
65 Account: bkAccount,
66 timer: time.NewTimer(time.Second * 15),
67 started: false,
68 ledger: ledger.DefLedger,
69 incrValidator: increment.NewIncrementValidator(20),
70 poolActor: &actorTypes.TxPoolActor{Pool: txpool},
71 p2p: &actorTypes.P2PActor{P2P: p2p},
72 }
73
74 if !service.timer.Stop() {
75 <-service.timer.C
76 }
77
78 go func() {
79 for {
80 select {
81 case <-service.timer.C:
82 log.Debug("******Get a timeout notice")
83 service.pid.Tell(&actorTypes.TimeOut{})
84 }
85 }
86 }()
87
88 props := actor.FromProducer(func() actor.Actor {
89 return service
90 })
91
92 pid, err := actor.SpawnNamed(props, "consensus_dbft")
93 service.pid = pid
94
95 service.sub = events.NewActorSubscriber(pid)
96 return service, err
97}
98
99func (this *DbftService) Receive(context actor.Context) {
100 if _, ok := context.Message().(*actorTypes.StartConsensus); this.started == false && ok == false {

Callers 1

NewConsensusServiceFunction · 0.92

Calls 4

NewIncrementValidatorFunction · 0.92
DebugFunction · 0.92
NewActorSubscriberFunction · 0.92
StopMethod · 0.65

Tested by

no test coverage detected