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

Method verifyTx

txnpool/proc/txnpool_worker.go:179–213  ·  view source on GitHub ↗

verifyTx prepares a check request and sends it to the validators.

(tx *tx.Transaction)

Source from the content-addressed store, hash-verified

177
178// verifyTx prepares a check request and sends it to the validators.
179func (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.
216func (worker *txPoolWorker) reVerifyTx(txHash common.Uint256) {

Callers 1

startMethod · 0.95

Calls 5

sendReq2ValidatorMethod · 0.95
DebugfFunction · 0.92
getTransactionMethod · 0.80
removePendingTxMethod · 0.80
HashMethod · 0.65

Tested by

no test coverage detected