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

Method ProcessBlock

src/masternode.cpp:815–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

813}
814
815bool CMasternodePayments::ProcessBlock(int nBlockHeight) {
816 LOCK(cs_masternodes);
817 if (!enabled) return false;
818 CMasternodePaymentWinner winner;
819
820 std::vector <CTxIn> vecLastPayments;
821 int c = 0;
822 for (CMasternodePaymentWinner& winner : reverse_iterate(vWinning)) {
823 vecLastPayments.push_back(winner.vin);
824 //if we have one full payment cycle, break
825 if (++c > (int) vecMasternodes.size()) break;
826 }
827
828 std::random_shuffle(vecMasternodes.begin(), vecMasternodes.end());
829 for (CMasterNode& mn : vecMasternodes) {
830 bool found = false;
831 for (CTxIn & vin : vecLastPayments)
832 if (mn.vin == vin) found = true;
833
834 if (found) continue;
835
836 mn.Check();
837 if (!mn.IsEnabled()) {
838 continue;
839 }
840
841 winner.score = 0;
842 winner.nBlockHeight = nBlockHeight;
843 winner.vin = mn.vin;
844 winner.payee = GetScriptForDestination(mn.pubkey.GetID());
845
846 break;
847 }
848
849 //if we can't find someone to get paid, pick randomly
850 if (winner.nBlockHeight == 0 && vecMasternodes.size() > 0) {
851 winner.score = 0;
852 winner.nBlockHeight = nBlockHeight;
853 winner.vin = vecMasternodes[0].vin;
854 winner.payee = GetScriptForDestination(vecMasternodes[0].pubkey.GetID());
855 }
856
857 if (Sign(winner)) {
858 if (AddWinningMasternode(winner)) {
859 Relay(winner);
860 return true;
861 }
862 }
863
864 return false;
865}
866
867void CMasternodePayments::Relay(CMasternodePaymentWinner& winner) {
868 CInv inv(MSG_MASTERNODE_WINNER, winner.GetHash());

Callers 15

TruncatedFinalMethod · 0.80
GenerateSubKeysMethod · 0.80
TransformRegisterMethod · 0.80
WriteKeystreamMethod · 0.80
ProcessLastBlockMethod · 0.80
SetKeyWithoutResyncMethod · 0.80
UncheckedSetKeyMethod · 0.80
UpdateMethod · 0.80
ProcessBufMethod · 0.80

Calls 10

reverse_iterateFunction · 0.85
GetScriptForDestinationFunction · 0.85
SignEnum · 0.85
IsEnabledMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
CheckMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected