(account *account.Account, txpool, p2p *actor.PID)
| 133 | } |
| 134 | |
| 135 | func 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 | |
| 163 | func (self *Server) Receive(context actor.Context) { |
| 164 | switch msg := context.Message().(type) { |
no test coverage detected