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

Function GetMasternodeByRank

src/masternode.cpp:477–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477int GetMasternodeByRank(int findRank, int64_t nBlockHeight, int minProtocol) {
478 LOCK(cs_masternodes);
479 int i = 0;
480
481 std::vector <pair<unsigned int, int>> vecMasternodeScores;
482
483 i = 0;
484 for (CMasterNode mn : vecMasternodes) {
485 mn.Check();
486 if (mn.protocolVersion < minProtocol) continue;
487 if (!mn.IsEnabled()) {
488 i++;
489 continue;
490 }
491
492 uint256 n = mn.CalculateScore(1, nBlockHeight);
493 unsigned int n2 = 0;
494 memcpy(&n2, &n, sizeof(n2));
495
496 vecMasternodeScores.push_back(make_pair(n2, i));
497 i++;
498 }
499
500 sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareValueOnly2());
501
502 int rank = 0;
503 for (PAIRTYPE(unsigned int, int) &s : vecMasternodeScores) {
504 rank++;
505 if (rank == findRank) return s.second;
506 }
507
508 return -1;
509}
510
511int GetMasternodeRank(CTxIn& vin, int64_t nBlockHeight, int minProtocol) {
512 //LOCK(cs_masternodes);

Callers

nothing calls this directly

Calls 8

memcpyFunction · 0.85
CompareValueOnly2Class · 0.85
IsEnabledMethod · 0.80
CalculateScoreMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
CheckMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected