removePendingTx removes a transaction from the pending list when it is handled. And if the submitter of the valid transaction is from http, broadcast it to the network. Meanwhile, check if it is in the block from consensus.
(hash common.Uint256, err errors.ErrCode)
| 258 | // is from http, broadcast it to the network. Meanwhile, check if it |
| 259 | // is in the block from consensus. |
| 260 | func (s *TXPoolServer) removePendingTx(hash common.Uint256, |
| 261 | err errors.ErrCode) { |
| 262 | |
| 263 | s.mu.Lock() |
| 264 | |
| 265 | pt, ok := s.allPendingTxs[hash] |
| 266 | if !ok { |
| 267 | s.mu.Unlock() |
| 268 | return |
| 269 | } |
| 270 | |
| 271 | if err == errors.ErrNoError && ((pt.sender == tc.HttpSender) || |
| 272 | (pt.sender == tc.NetSender && !s.disableBroadcastNetTx)) { |
| 273 | pid := s.GetPID(tc.NetActor) |
| 274 | if pid != nil { |
| 275 | pid.Tell(pt.tx) |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if pt.sender == tc.HttpSender && pt.ch != nil { |
| 280 | replyTxResult(pt.ch, hash, err, err.Error()) |
| 281 | } |
| 282 | |
| 283 | delete(s.allPendingTxs, hash) |
| 284 | |
| 285 | if len(s.allPendingTxs) < tc.MAX_LIMITATION { |
| 286 | select { |
| 287 | case s.slots <- struct{}{}: |
| 288 | default: |
| 289 | log.Debug("removePendingTx: slots is full") |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | s.mu.Unlock() |
| 294 | |
| 295 | // Check if the tx is in the pending block and |
| 296 | // the pending block is verified |
| 297 | s.checkPendingBlockOk(hash, err) |
| 298 | } |
| 299 | |
| 300 | // setPendingTx adds a transaction to the pending list, if the |
| 301 | // transaction is already in the pending list, just return false. |
no test coverage detected