| 446 | } |
| 447 | |
| 448 | int GetCurrentMasterNode(int mod, int64_t nBlockHeight, int minProtocol) { |
| 449 | int i = 0; |
| 450 | unsigned int score = 0; |
| 451 | int winner = -1; |
| 452 | //LOCK(cs_masternodes); |
| 453 | // scan for winner |
| 454 | for (CMasterNode mn : vecMasternodes) { |
| 455 | mn.Check(); |
| 456 | if (mn.protocolVersion < minProtocol) continue; |
| 457 | if (!mn.IsEnabled()) { |
| 458 | i++; |
| 459 | continue; |
| 460 | } |
| 461 | |
| 462 | // calculate the score for each masternode |
| 463 | uint256 n = mn.CalculateScore(mod, nBlockHeight); |
| 464 | unsigned int n2 = 0; |
| 465 | memcpy(&n2, &n, sizeof(n2)); |
| 466 | |
| 467 | // determine the winner |
| 468 | if (n2 > score) { |
| 469 | score = n2; |
| 470 | winner = i; |
| 471 | } |
| 472 | i++; |
| 473 | } |
| 474 | return winner; |
| 475 | } |
| 476 | |
| 477 | int GetMasternodeByRank(int findRank, int64_t nBlockHeight, int minProtocol) { |
| 478 | LOCK(cs_masternodes); |
no test coverage detected