MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / processPendingTxs

Method processPendingTxs

cmd/cql-eth-exchange/exchange.go:444–530  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

442}
443
444func (e *Exchange) processPendingTxs() {
445 var (
446 records []*TxRecord
447 err error
448 )
449
450 lastAvailBlock := atomic.LoadUint64(&e.currentBlock) - e.cfg.DelayBlockCount
451 records, err = GetToProcessTx(e.metaDatabase, lastAvailBlock)
452 if err != nil {
453 return
454 }
455
456 // get current balance
457 var balance uint64
458 balance, err = e.getAccountBalance()
459 if err != nil {
460 return
461 }
462
463 // get current nonce
464 var nonce cinter.AccountNonce
465 nonce, err = e.getAccountNonce()
466 if err != nil {
467 return
468 }
469
470 for _, r := range records {
471 if r.CQLAmount > balance {
472 // skip this tx, account
473 _ = AddAuditRecord(e.metaDatabase, &AuditRecord{
474 Hash: r.Hash,
475 Op: "check_balance",
476 Data: map[string]interface{}{
477 "required": r.CQLAmount,
478 "balance": balance,
479 },
480 })
481 continue
482 }
483
484 // send request and update state
485 // parse cql account
486 var target proto.AccountAddress
487 err = hash.Decode((*hash.Hash)(&target), r.CQLAccount)
488 if err != nil {
489 _ = AddAuditRecord(e.metaDatabase, &AuditRecord{
490 Hash: r.Hash,
491 Op: "invalid_target_account",
492 Data: map[string]interface{}{
493 "account": r.CQLAccount,
494 },
495 })
496 }
497
498 var txHash hash.Hash
499 txHash, err = e.transferToken(target, nonce, r.CQLAmount)
500 _ = AddAuditRecord(e.metaDatabase, &AuditRecord{
501 Hash: r.Hash,

Callers 1

processMethod · 0.95

Calls 7

getAccountBalanceMethod · 0.95
getAccountNonceMethod · 0.95
transferTokenMethod · 0.95
DecodeFunction · 0.92
GetToProcessTxFunction · 0.85
AddAuditRecordFunction · 0.85
SetTxToTransferringFunction · 0.85

Tested by

no test coverage detected