| 475 | } |
| 476 | |
| 477 | int 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 | |
| 511 | int GetMasternodeRank(CTxIn& vin, int64_t nBlockHeight, int minProtocol) { |
| 512 | //LOCK(cs_masternodes); |
nothing calls this directly
no test coverage detected