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

Method checkPendingBlockOk

txnpool/proc/txnpool_server.go:199–226  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

197// If some transaction is invalid, return the result directly at once, no
198// need to wait for verifying the complete block.
199func (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.
229func (s *TXPoolServer) getPendingListSize() int {

Callers 1

removePendingTxMethod · 0.95

Calls 1

Tested by

no test coverage detected