Skip to content

Commit

Permalink
Change operation of fEnableSideStaking flag
Browse files Browse the repository at this point in the history
The fEnableSideStaking flag should only control local sidestakes,
not mandatory ones.
  • Loading branch information
jamescowens committed Oct 2, 2023
1 parent 48118d2 commit 82eb56c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
18 changes: 12 additions & 6 deletions src/gridcoin/sidestake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,18 @@ const std::vector<SideStake_ptr> SideStakeRegistry::ActiveSideStakeEntries()
}
}

// Followed by local active sidestakes
for (const auto& entry : m_sidestake_entries)
{
if (entry.second->m_status == SideStakeStatus::ACTIVE && allocation_sum + entry.second->m_allocation <= 1.0) {
sidestakes.push_back(entry.second);
allocation_sum += entry.second->m_allocation;
// Followed by local active sidestakes if sidestaking is enabled. Note that mandatory sidestaking cannot be disabled.
bool fEnableSideStaking = gArgs.GetBoolArg("-enablesidestaking");

if (fEnableSideStaking) {
LogPrint(BCLog::LogFlags::MINER, "INFO: %s: fEnableSideStaking = %u", __func__, fEnableSideStaking);

for (const auto& entry : m_sidestake_entries)
{
if (entry.second->m_status == SideStakeStatus::ACTIVE && allocation_sum + entry.second->m_allocation <= 1.0) {
sidestakes.push_back(entry.second);
allocation_sum += entry.second->m_allocation;
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,9 @@ void StakeMiner(CWallet *pwallet)

bool fEnableSideStaking = gArgs.GetBoolArg("-enablesidestaking");

LogPrint(BCLog::LogFlags::MINER, "INFO: %s: fEnableSideStaking = %u", __func__, fEnableSideStaking);

// vSideStakeAlloc is an out parameter.
if (fEnableSideStaking) vSideStakeAlloc = GRC::GetSideStakeRegistry().ActiveSideStakeEntries();
// Note that fEnableSideStaking is now processed internal to ActiveSideStakeEntries. The sidestaking flag only
// controls local sidestakes. If there exists mandatory sidestakes, they occur regardless of the flag.
vSideStakeAlloc = GRC::GetSideStakeRegistry().ActiveSideStakeEntries();

// wait for next round
if (!MilliSleep(nMinerSleep)) return;
Expand Down
22 changes: 11 additions & 11 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ UniValue getstakinginfo(const UniValue& params, bool fHelp)
}
obj.pushKV("stake-splitting", stakesplitting);

sidestaking.pushKV("side-staking-enabled", fEnableSideStaking);
if (fEnableSideStaking)
sidestaking.pushKV("local_side_staking_enabled", fEnableSideStaking);

// Note that if local_side_staking_enabled is true, then local sidestakes will be applicable and shown. Mandatory
// sidestakes are always included.
for (const auto& alloc : vSideStakeAlloc)
{
for (const auto& alloc : vSideStakeAlloc)
{
sidestakingalloc.pushKV("address", alloc->m_key.ToString());
sidestakingalloc.pushKV("allocation-pct", alloc->m_allocation * 100);
sidestakingalloc.pushKV("status", alloc->StatusToString());
sidestakingalloc.pushKV("address", alloc->m_key.ToString());
sidestakingalloc.pushKV("allocation_pct", alloc->m_allocation * 100);
sidestakingalloc.pushKV("status", alloc->StatusToString());

vsidestakingalloc.push_back(sidestakingalloc);
}
sidestaking.pushKV("side-staking-allocations", vsidestakingalloc);
vsidestakingalloc.push_back(sidestakingalloc);
}
obj.pushKV("side-staking", sidestaking);
sidestaking.pushKV("side_staking_allocations", vsidestakingalloc);
obj.pushKV("side_staking", sidestaking);

obj.pushKV("difficulty", diff);
obj.pushKV("errors", GetWarnings("statusbar"));
Expand Down

0 comments on commit 82eb56c

Please sign in to comment.