| 20 | } |
| 21 | |
| 22 | static bool GenPendingDelegates(CBlock &block, uint32_t delegateNum, CCacheWrapper &cw, |
| 23 | const VoteDelegateVector activeDelegates, |
| 24 | PendingDelegates &pendingDelegates, bool isR3Fork) { |
| 25 | |
| 26 | auto version = GetFeatureForkVersion(block.GetHeight()); |
| 27 | pendingDelegates.counted_vote_height = block.GetHeight(); |
| 28 | uint64_t BpMinVote = 0; |
| 29 | if (version < MAJOR_VER_R3_5) { |
| 30 | if (!cw.sysParamCache.GetParam(SysParamType::BP_DELEGATE_VOTE_MIN, BpMinVote)) |
| 31 | return ERRORMSG("get sys param BP_DELEGATE_VOTE_MIN failed! block=%d:%s\n", |
| 32 | block.GetHeight(), block.GetHash().ToString()); |
| 33 | } // else { BP_DELEGATE_VOTE_MIN will be deprecated after MAJOR_VER_R3_5 } |
| 34 | |
| 35 | VoteDelegateVector topVoteDelegates; |
| 36 | if (!cw.delegateCache.GetTopVoteDelegates(delegateNum, BpMinVote, topVoteDelegates, isR3Fork)) { |
| 37 | LogPrint(BCLog::INFO, "[WARN] [%d] GetTopVoteDelegates() failed! no need to update pending delegates! " |
| 38 | "block=%s, delegate_num=%d\n", block.GetHeight(), block.GetHash().ToString(), delegateNum); |
| 39 | |
| 40 | return true; |
| 41 | }; |
| 42 | |
| 43 | pendingDelegates.top_vote_delegates = topVoteDelegates; |
| 44 | |
| 45 | if (!activeDelegates.empty() && pendingDelegates.top_vote_delegates == activeDelegates) { |
| 46 | LogPrint(BCLog::INFO, "[%d] The top vote delegates are unchanged! block=%s, num=%d, dest_num=%d\n", |
| 47 | block.GetHeight(), block.GetHash().ToString(), pendingDelegates.top_vote_delegates.size(), delegateNum); |
| 48 | // update counted_vote_height and top_vote_delegates to skip unchanged delegates to next count vote slot height |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | LogPrint(BCLog::DELEGATE, "Gen new pending delegates={%s}\n", pendingDelegates.ToString()); |
| 53 | pendingDelegates.state = VoteDelegateState::PENDING; |
| 54 | |
| 55 | return true; |
| 56 | } |
| 57 | |
| 58 | bool chain::IsBlockInflatedRewardStarted(CCacheWrapper &cw, HeightType height) { |
| 59 | auto version = GetFeatureForkVersion(height); |
no test coverage detected