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

Method handleTimeoutEvent

txnpool/proc/txnpool_worker.go:141–164  ·  view source on GitHub ↗

* 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 */

()

Source from the content-addressed store, hash-verified

139 * long, need to change the algorithm later
140 */
141func (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.

Callers 1

startMethod · 0.95

Calls 5

reVerifyTxMethod · 0.95
DebugfFunction · 0.92
SubMethod · 0.80
removePendingTxMethod · 0.80
ToArrayMethod · 0.65

Tested by

no test coverage detected