Receive implements the actor interface
(context actor.Context)
| 229 | |
| 230 | // Receive implements the actor interface |
| 231 | func (tpa *TxPoolActor) Receive(context actor.Context) { |
| 232 | switch msg := context.Message().(type) { |
| 233 | case *actor.Started: |
| 234 | log.Info("txpool actor started and be ready to receive txPool msg") |
| 235 | |
| 236 | case *actor.Stopping: |
| 237 | log.Warn("txpool actor stopping") |
| 238 | |
| 239 | case *actor.Restarting: |
| 240 | log.Warn("txpool actor Restarting") |
| 241 | |
| 242 | case *tc.GetTxnPoolReq: |
| 243 | sender := context.Sender() |
| 244 | |
| 245 | log.Debugf("txpool actor receives getting tx pool req from %v", sender) |
| 246 | |
| 247 | res := tpa.server.getTxPool(msg.ByCount, msg.Height) |
| 248 | if sender != nil { |
| 249 | sender.Request(&tc.GetTxnPoolRsp{TxnPool: res}, context.Self()) |
| 250 | } |
| 251 | |
| 252 | case *tc.GetPendingTxnReq: |
| 253 | sender := context.Sender() |
| 254 | |
| 255 | log.Debugf("txpool actor receives getting pedning tx req from %v", sender) |
| 256 | |
| 257 | res := tpa.server.getPendingTxs(msg.ByCount) |
| 258 | if sender != nil { |
| 259 | sender.Request(&tc.GetPendingTxnRsp{Txs: res}, context.Self()) |
| 260 | } |
| 261 | |
| 262 | case *tc.VerifyBlockReq: |
| 263 | sender := context.Sender() |
| 264 | |
| 265 | log.Debugf("txpool actor receives verifying block req from %v", sender) |
| 266 | |
| 267 | tpa.server.verifyBlock(msg, sender) |
| 268 | |
| 269 | case *message.SaveBlockCompleteMsg: |
| 270 | sender := context.Sender() |
| 271 | |
| 272 | log.Debugf("txpool actor receives block complete event from %v", sender) |
| 273 | |
| 274 | if msg.Block != nil { |
| 275 | tpa.server.cleanTransactionList(msg.Block.Transactions, msg.Block.Header.Height) |
| 276 | } |
| 277 | |
| 278 | default: |
| 279 | log.Debugf("txpool actor: unknown msg %v type %v", msg, reflect.TypeOf(msg)) |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | func (tpa *TxPoolActor) setServer(s *TXPoolServer) { |
| 284 | tpa.server = s |
nothing calls this directly
no test coverage detected