Skip to content

Commit

Permalink
Implement ActiveSideStakeEntries()
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Oct 2, 2023
1 parent 02736aa commit a8024cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/gridcoin/sidestake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@ const SideStakeRegistry::SideStakeMap& SideStakeRegistry::SideStakeEntries() con
return m_sidestake_entries;
}

const std::vector<SideStake_ptr> SideStakeRegistry::ActiveSideStakeEntries() const
{
std::vector<SideStake_ptr> sidestakes;

for (const auto& entry : m_sidestake_entries)
{
if (entry.second->m_status == SideStakeStatus::ACTIVE || entry.second->m_status == SideStakeStatus::MANDATORY) {
sidestakes.push_back(entry.second);
}
}

return sidestakes;
}

SideStakeOption SideStakeRegistry::Try(const CBitcoinAddressForStorage& key) const
{
LOCK(cs_lock);
Expand Down
9 changes: 9 additions & 0 deletions src/gridcoin/sidestake.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ class SideStakeRegistry : public IContractHandler
//!
const SideStakeMap& SideStakeEntries() const;

//!
//! \brief Get the collection of active sidestake entries. This is presented as a vector of
//! smart pointers to the relevant sidestake entries in the database. The entries included have
//! the status of active (for local sidestakes) and/or mandatory (for contract sidestakes).
//!
//! \return A vector of smart pointers to sidestake entries.
//!
const std::vector<SideStake_ptr> ActiveSideStakeEntries() const;

//!
//! \brief Get the current sidestake entry for the specified key string.
//!
Expand Down

0 comments on commit a8024cf

Please sign in to comment.