src/wallet/node_rpc_proxy.cpp
// Filtered version of the above that caches the filtered result as long as used on the same
// contributor at the same height (which is very common, for example, for wallet balance lookups).
Filtered version of the above that caches the filtered result as long as used on the same
contributor at the same height (which is very common, for example, for wallet balance lookups).
Filtered version of the above that caches the filtered result as long as used on the same contributor at the same height ( which is very common for example for wallet balance lookups ) .
std::pair<bool, std::vector<cryptonote::rpc::GET_MASTER_NODES::response::entry>> NodeRPCProxy::get_contributed_master_nodes(const std::string &contributor) const
{
  std::pair<bool, std::vector<cryptonote::rpc::GET_MASTER_NODES::response::entry>> result;
  auto& [success, mns] = result;
  success = false;
  uint64_t height;
  if (m_offline || !get_height(height))
    return result;
  {
    std::lock_guard lock{m_mn_cache_mutex};
    if (m_contributed_master_nodes_cached_height != height || m_contributed_master_nodes_cached_address != contributor) {
      if (m_all_master_nodes_cached_height != height && !update_all_master_nodes_cache(height))
        return result;
      m_contributed_master_nodes.clear();
      std::copy_if(m_all_master_nodes.begin(), m_all_master_nodes.end(), std::back_inserter(m_contributed_master_nodes),
          [&contributor](const auto& mn)
          {
            return std::any_of(mn.contributors.begin(), mn.contributors.end(),
                [&contributor](const auto& c) { return contributor == c.address; });
          }
      );
      m_contributed_master_nodes_cached_height = height;
      m_contributed_master_nodes_cached_address = contributor;
    }
    mns = m_contributed_master_nodes;
  }
  success = true;
  return result;
}
std :: pair < bool , std :: vector < cryptonote :: rpc :: GET_MASTER_NODES :: response :: entry > > NodeRPCProxy :: get_contributed_master_nodes ( const std :: string & contributor ) const { std :: pair < bool , std :: vector < cryptonote :: rpc :: GET_MASTER_NODES :: response :: entry > > result ; auto & [ success , mns ] = result ; success = false ; uint64_t height ; if ( m_offline || ! get_height ( height ) ) return result ; { std :: lock_guard lock { m_mn_cache_mutex } ; if ( m_contributed_master_nodes_cached_height != height || m_contributed_master_nodes_cached_address != contributor ) { if ( m_all_master_nodes_cached_height != height && ! update_all_master_nodes_cache ( height ) ) return result ; m_contributed_master_nodes . clear ( ) ; std :: copy_if ( m_all_master_nodes . begin ( ) , m_all_master_nodes . end ( ) , std :: back_inserter ( m_contributed_master_nodes ) , [ & contributor ] ( const auto & mn ) { return std :: any_of ( mn . contributors . begin ( ) , mn . contributors . end ( ) , [ & contributor ] ( const auto & c ) { return contributor == c . address ; } ) ; } ) ; m_contributed_master_nodes_cached_height = height ; m_contributed_master_nodes_cached_address = contributor ; } mns = m_contributed_master_nodes ; } success = true ; return result ; }
Filtered version of the above that caches the filtered result as long as used on the same
contributor at the same height (which is very common, for example, for wallet balance lookups).
Filtered version of the above that caches the filtered result as long as used on the same contributor at the same height ( which is very common for example for wallet balance lookups ) .