* Check if the transaction need to be sent to validator to verify * when time out. * Todo: Going through the list will take time if the list is too * long, need to change the algorithm later */
()
| 139 | * long, need to change the algorithm later |
| 140 | */ |
| 141 | func (worker *txPoolWorker) handleTimeoutEvent() { |
| 142 | if len(worker.pendingTxList) <= 0 { |
| 143 | return |
| 144 | } |
| 145 | |
| 146 | /* Go through the pending list, for those unverified txns, |
| 147 | * resend them to the validators |
| 148 | */ |
| 149 | for k, v := range worker.pendingTxList { |
| 150 | if v.flag&0xf != tc.VERIFY_MASK && (time.Now().Sub(v.valTime)/time.Second) >= |
| 151 | tc.EXPIRE_INTERVAL { |
| 152 | if v.retries < tc.MAX_RETRIES { |
| 153 | worker.reVerifyTx(k) |
| 154 | v.retries++ |
| 155 | } else { |
| 156 | log.Debugf("retry to verify transaction exhausted %x", k.ToArray()) |
| 157 | worker.mu.Lock() |
| 158 | delete(worker.pendingTxList, k) |
| 159 | worker.mu.Unlock() |
| 160 | worker.server.removePendingTx(k, errors.ErrRetryExhausted) |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // putTxPool adds a valid transaction to the tx pool and removes it from |
| 167 | // the pending list. |
no test coverage detected