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

Method Receive

txnpool/proc/txnpool_actor.go:231–281  ·  view source on GitHub ↗

Receive implements the actor interface

(context actor.Context)

Source from the content-addressed store, hash-verified

229
230// Receive implements the actor interface
231func (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
283func (tpa *TxPoolActor) setServer(s *TXPoolServer) {
284 tpa.server = s

Callers

nothing calls this directly

Calls 8

InfoFunction · 0.92
WarnFunction · 0.92
DebugfFunction · 0.92
SenderMethod · 0.80
getTxPoolMethod · 0.80
getPendingTxsMethod · 0.80
verifyBlockMethod · 0.80
cleanTransactionListMethod · 0.80

Tested by

no test coverage detected