checkPendingBlockOk checks whether a block from consensus is verified. If some transaction is invalid, return the result directly at once, no need to wait for verifying the complete block.
(hash common.Uint256, err errors.ErrCode)
| 197 | // If some transaction is invalid, return the result directly at once, no |
| 198 | // need to wait for verifying the complete block. |
| 199 | func (s *TXPoolServer) checkPendingBlockOk(hash common.Uint256, |
| 200 | err errors.ErrCode) { |
| 201 | |
| 202 | // Check if the tx is in pending block, if yes, move it to |
| 203 | // the verified tx list |
| 204 | s.pendingBlock.mu.Lock() |
| 205 | defer s.pendingBlock.mu.Unlock() |
| 206 | |
| 207 | tx, ok := s.pendingBlock.unProcessedTxs[hash] |
| 208 | if !ok { |
| 209 | return |
| 210 | } |
| 211 | |
| 212 | entry := &tc.VerifyTxResult{ |
| 213 | Height: s.pendingBlock.height, |
| 214 | Tx: tx, |
| 215 | ErrCode: err, |
| 216 | } |
| 217 | |
| 218 | s.pendingBlock.processedTxs[hash] = entry |
| 219 | delete(s.pendingBlock.unProcessedTxs, hash) |
| 220 | |
| 221 | // if the tx is invalid, send the response at once |
| 222 | if err != errors.ErrNoError || |
| 223 | len(s.pendingBlock.unProcessedTxs) == 0 { |
| 224 | s.sendBlkResult2Consensus() |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // getPendingListSize return the length of the pending tx list. |
| 229 | func (s *TXPoolServer) getPendingListSize() int { |
no test coverage detected