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

Method Receive

txnpool/proc/txnpool_actor.go:138–219  ·  view source on GitHub ↗

Receive implements the actor interface

(context actor.Context)

Source from the content-addressed store, hash-verified

136
137// Receive implements the actor interface
138func (ta *TxActor) Receive(context actor.Context) {
139 switch msg := context.Message().(type) {
140 case *actor.Started:
141 log.Info("txpool-tx actor started and be ready to receive tx msg")
142
143 case *actor.Stopping:
144 log.Warn("txpool-tx actor stopping")
145
146 case *actor.Restarting:
147 log.Warn("txpool-tx actor restarting")
148
149 case *tc.TxReq:
150 sender := msg.Sender
151
152 log.Debugf("txpool-tx actor receives tx from %v ", sender.Sender())
153
154 ta.handleTransaction(sender, context.Self(), msg.Tx, msg.TxResultCh)
155
156 case *tc.GetTxnReq:
157 sender := context.Sender()
158
159 log.Debugf("txpool-tx actor receives getting tx req from %v", sender)
160
161 res := ta.server.getTransaction(msg.Hash)
162 if sender != nil {
163 sender.Request(&tc.GetTxnRsp{Txn: res},
164 context.Self())
165 }
166
167 case *tc.GetTxnStats:
168 sender := context.Sender()
169
170 log.Debugf("txpool-tx actor receives getting tx stats from %v", sender)
171
172 res := ta.server.getStats()
173 if sender != nil {
174 sender.Request(&tc.GetTxnStatsRsp{Count: res},
175 context.Self())
176 }
177
178 case *tc.CheckTxnReq:
179 sender := context.Sender()
180
181 log.Debugf("txpool-tx actor receives checking tx req from %v", sender)
182
183 res := ta.server.checkTx(msg.Hash)
184 if sender != nil {
185 sender.Request(&tc.CheckTxnRsp{Ok: res},
186 context.Self())
187 }
188
189 case *tc.GetTxnStatusReq:
190 sender := context.Sender()
191
192 log.Debugf("txpool-tx actor receives getting tx status req from %v", sender)
193
194 res := ta.server.getTxStatusReq(msg.Hash)
195 if sender != nil {

Callers

nothing calls this directly

Calls 10

handleTransactionMethod · 0.95
InfoFunction · 0.92
WarnFunction · 0.92
DebugfFunction · 0.92
SenderMethod · 0.80
getTransactionMethod · 0.80
getStatsMethod · 0.80
checkTxMethod · 0.80
getTxStatusReqMethod · 0.80
getTxCountMethod · 0.80

Tested by

no test coverage detected