verifyTx prepares a check request and sends it to the validators.
(tx *tx.Transaction)
| 177 | |
| 178 | // verifyTx prepares a check request and sends it to the validators. |
| 179 | func (worker *txPoolWorker) verifyTx(tx *tx.Transaction) { |
| 180 | if tx := worker.server.getTransaction(tx.Hash()); tx != nil { |
| 181 | log.Debugf("verifyTx: transaction %x already in the txn pool", |
| 182 | tx.Hash()) |
| 183 | worker.server.removePendingTx(tx.Hash(), errors.ErrDuplicateInput) |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | if _, ok := worker.pendingTxList[tx.Hash()]; ok { |
| 188 | log.Debugf("verifyTx: transaction %x already in the verifying process", |
| 189 | tx.Hash()) |
| 190 | return |
| 191 | } |
| 192 | // Construct the request and send it to each validator server to verify |
| 193 | req := &types.CheckTx{ |
| 194 | WorkerId: worker.workId, |
| 195 | Tx: tx, |
| 196 | } |
| 197 | |
| 198 | worker.sendReq2Validator(req) |
| 199 | |
| 200 | // Construct the pending transaction |
| 201 | pt := &pendingTx{ |
| 202 | tx: tx, |
| 203 | req: req, |
| 204 | flag: 0, |
| 205 | retries: 0, |
| 206 | } |
| 207 | // Add it to the pending transaction list |
| 208 | worker.mu.Lock() |
| 209 | worker.pendingTxList[tx.Hash()] = pt |
| 210 | worker.mu.Unlock() |
| 211 | // Record the time per a txn |
| 212 | pt.valTime = time.Now() |
| 213 | } |
| 214 | |
| 215 | // reVerifyTx re-sends a check request to the validators. |
| 216 | func (worker *txPoolWorker) reVerifyTx(txHash common.Uint256) { |
no test coverage detected