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

Function NewVbftServer

consensus/vbft/service.go:135–161  ·  view source on GitHub ↗
(account *account.Account, txpool, p2p *actor.PID)

Source from the content-addressed store, hash-verified

133}
134
135func NewVbftServer(account *account.Account, txpool, p2p *actor.PID) (*Server, error) {
136 server := &Server{
137 msgHistoryDuration: 64,
138 account: account,
139 poolActor: &actorTypes.TxPoolActor{Pool: txpool},
140 p2p: &actorTypes.P2PActor{P2P: p2p},
141 ledger: ledger.DefLedger,
142 incrValidator: increment.NewIncrementValidator(20),
143 }
144 server.stateMgr = newStateMgr(server)
145
146 props := actor.FromProducer(func() actor.Actor {
147 return server
148 })
149
150 pid, err := actor.SpawnNamed(props, "consensus_vbft")
151 if err != nil {
152 return nil, err
153 }
154 server.pid = pid
155 server.sub = events.NewActorSubscriber(pid)
156
157 if err := server.initialize(); err != nil {
158 return nil, fmt.Errorf("vbft server start failed: %s", err)
159 }
160 return server, nil
161}
162
163func (self *Server) Receive(context actor.Context) {
164 switch msg := context.Message().(type) {

Callers 1

NewConsensusServiceFunction · 0.92

Calls 5

initializeMethod · 0.95
NewIncrementValidatorFunction · 0.92
NewActorSubscriberFunction · 0.92
newStateMgrFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected