add some helper routines to the peer list lookup;

pull/86/head
Bryan Biedenkapp 11 months ago
parent cb335cffed
commit b1f10a87ab

@ -152,6 +152,20 @@ PeerListLookup::Mode PeerListLookup::getMode() const
return m_mode; return m_mode;
} }
/* Gets the entire peer ID table. */
std::vector<PeerId> PeerListLookup::tableAsList() const
{
std::vector<PeerId> ret = std::vector<PeerId>();
std::lock_guard<std::mutex> lock(m_mutex);
for (auto entry : m_table) {
ret.push_back(entry.second);
}
return ret;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Private Class Members // Private Class Members
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

@ -110,19 +110,19 @@ namespace lookups
/** /**
* @brief Peer ID. * @brief Peer ID.
*/ */
__READONLY_PROPERTY_PLAIN(uint32_t, peerId); __PROPERTY_PLAIN(uint32_t, peerId);
/** /**
* @breif Peer Alias * @breif Peer Alias
*/ */
__READONLY_PROPERTY_PLAIN(std::string, peerAlias); __PROPERTY_PLAIN(std::string, peerAlias);
/** /**
* @brief Per Peer Password. * @brief Per Peer Password.
*/ */
__READONLY_PROPERTY_PLAIN(std::string, peerPassword); __PROPERTY_PLAIN(std::string, peerPassword);
/** /**
* @brief Flag indicating if the peer participates in peer link and should be sent configuration. * @brief Flag indicating if the peer participates in peer link and should be sent configuration.
*/ */
__READONLY_PROPERTY_PLAIN(bool, peerLink); __PROPERTY_PLAIN(bool, peerLink);
/** /**
* @brief Flag indicating if the peer is default. * @brief Flag indicating if the peer is default.
*/ */
@ -221,6 +221,17 @@ namespace lookups
*/ */
Mode getMode() const; Mode getMode() const;
/**
* @brief Gets the entire peer ID table.
* @returns std::unordered_map<uint32_t, PeerId>
*/
std::unordered_map<uint32_t, PeerId> table() const { return m_table; }
/**
* @brief Gets the entire peer ID table.
* @returns std::vector<PeerId>
*/
std::vector<PeerId> tableAsList() const;
protected: protected:
bool m_acl; bool m_acl;

Loading…
Cancel
Save

Powered by TurnKey Linux.