Implementation of IsSuperMajority with better feedback */
| 573 | |
| 574 | /** Implementation of IsSuperMajority with better feedback */ |
| 575 | UniValue SoftForkMajorityDesc(int minVersion, CBlockIndex* pindex, int nRequired, const Consensus::Params& consensusParams) |
| 576 | { |
| 577 | int nFound = 0; |
| 578 | CBlockIndex* pstart = pindex; |
| 579 | for (int i = 0; i < consensusParams.nMajorityWindow && pstart != NULL; i++) |
| 580 | { |
| 581 | if (pstart->nVersion >= minVersion) |
| 582 | ++nFound; |
| 583 | pstart = pstart->pprev; |
| 584 | } |
| 585 | |
| 586 | UniValue rv(UniValue::VOBJ); |
| 587 | rv.push_back(Pair("status", nFound >= nRequired)); |
| 588 | rv.push_back(Pair("found", nFound)); |
| 589 | rv.push_back(Pair("required", nRequired)); |
| 590 | rv.push_back(Pair("window", consensusParams.nMajorityWindow)); |
| 591 | return rv; |
| 592 | } |
| 593 | |
| 594 | UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams) |
| 595 | { |
no test coverage detected