From b1f10a87ab56c733c27c00d7b772ad18270d69f9 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sun, 9 Mar 2025 11:28:03 -0400 Subject: [PATCH] add some helper routines to the peer list lookup; --- src/common/lookups/PeerListLookup.cpp | 14 ++++++++++++++ src/common/lookups/PeerListLookup.h | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/common/lookups/PeerListLookup.cpp b/src/common/lookups/PeerListLookup.cpp index 5552a928..f4112499 100644 --- a/src/common/lookups/PeerListLookup.cpp +++ b/src/common/lookups/PeerListLookup.cpp @@ -152,6 +152,20 @@ PeerListLookup::Mode PeerListLookup::getMode() const return m_mode; } +/* Gets the entire peer ID table. */ + +std::vector PeerListLookup::tableAsList() const +{ + std::vector ret = std::vector(); + + std::lock_guard lock(m_mutex); + for (auto entry : m_table) { + ret.push_back(entry.second); + } + + return ret; +} + // --------------------------------------------------------------------------- // Private Class Members // --------------------------------------------------------------------------- diff --git a/src/common/lookups/PeerListLookup.h b/src/common/lookups/PeerListLookup.h index b1b318ba..494ec13f 100644 --- a/src/common/lookups/PeerListLookup.h +++ b/src/common/lookups/PeerListLookup.h @@ -110,19 +110,19 @@ namespace lookups /** * @brief Peer ID. */ - __READONLY_PROPERTY_PLAIN(uint32_t, peerId); + __PROPERTY_PLAIN(uint32_t, peerId); /** * @breif Peer Alias */ - __READONLY_PROPERTY_PLAIN(std::string, peerAlias); + __PROPERTY_PLAIN(std::string, peerAlias); /** * @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. */ - __READONLY_PROPERTY_PLAIN(bool, peerLink); + __PROPERTY_PLAIN(bool, peerLink); /** * @brief Flag indicating if the peer is default. */ @@ -221,6 +221,17 @@ namespace lookups */ Mode getMode() const; + /** + * @brief Gets the entire peer ID table. + * @returns std::unordered_map + */ + std::unordered_map table() const { return m_table; } + /** + * @brief Gets the entire peer ID table. + * @returns std::vector + */ + std::vector tableAsList() const; + protected: bool m_acl;