MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / GenPendingDelegates

Function GenPendingDelegates

src/chain/blockdelegates.cpp:22–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22static 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
58bool chain::IsBlockInflatedRewardStarted(CCacheWrapper &cw, HeightType height) {
59 auto version = GetFeatureForkVersion(height);

Callers 1

ProcessBlockDelegatesMethod · 0.85

Calls 8

GetFeatureForkVersionFunction · 0.85
GetParamMethod · 0.80
GetTopVoteDelegatesMethod · 0.80
GetHeightMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected