MCPcopy Create free account
hub / github.com/LUX-Core/lux / ChargeFees

Method ChargeFees

src/darksend.cpp:658–756  ·  view source on GitHub ↗

Charge clients a fee if they're abusive Why bother? Darksend uses collateral to ensure abuse to the process is kept to a minimum. The submission and signing stages in darksend are completely separate. In the cases where a client submits a transaction then refused to sign, there must be a cost. Otherwise they would be able to do this over and over again and bring the mixing to a hault. How does t

Source from the content-addressed store, hash-verified

656// until the transaction is either complete or fails.
657//
658void CDarkSendPool::ChargeFees() {
659 if (fMasterNode) {
660 //we don't need to charge collateral for every offence.
661 int offences = 0;
662 int r = rand() % 100;
663 if (r > 33) return;
664
665 if (state == POOL_STATUS_ACCEPTING_ENTRIES) {
666 for (const CTransaction& txCollateral : vecSessionCollateral) {
667 bool found = false;
668 for (const CDarkSendEntry& v : entries) {
669 if (v.collateral == txCollateral) {
670 found = true;
671 }
672 }
673
674 // This queue entry didn't send us the promised transaction
675 if (!found) {
676 LogPrintf("CDarkSendPool::ChargeFees -- found uncooperative node (didn't send transaction). Found offence.\n");
677 offences++;
678 }
679 }
680 }
681
682 if (state == POOL_STATUS_SIGNING) {
683 // who didn't sign?
684 for (const CDarkSendEntry v : entries) {
685 for (const CDarkSendEntryVin s : v.sev) {
686 if (!s.isSigSet) {
687 LogPrintf("CDarkSendPool::ChargeFees -- found uncooperative node (didn't sign). Found offence\n");
688 offences++;
689 }
690 }
691 }
692 }
693
694 r = rand() % 100;
695 int target = 0;
696
697 //mostly offending?
698 if (offences >= POOL_MAX_TRANSACTIONS - 1 && r > 33) return;
699
700 //everyone is an offender? That's not right
701 if (offences >= POOL_MAX_TRANSACTIONS) return;
702
703 //charge one of the offenders randomly
704 if (offences > 1) target = 50;
705
706 //pick random client to charge
707 r = rand() % 100;
708
709 if (state == POOL_STATUS_ACCEPTING_ENTRIES) {
710 for (const CTransaction& txCollateral : vecSessionCollateral) {
711 bool found = false;
712 for (const CDarkSendEntry& v : entries) {
713 if (v.collateral == txCollateral) {
714 found = true;
715 }

Callers

nothing calls this directly

Calls 2

AcceptToMemoryPoolMethod · 0.80
CWalletTxClass · 0.70

Tested by

no test coverage detected