mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
net: Providing an interface for mapLocalHost
Contributes to #564 by providing an interface for mapLocalHost through net -> node interface -> clientModel. Later this value can be read by GUI to show the local addresses.
This commit is contained in:
parent
058af75874
commit
a5d7aff867
6 changed files with 29 additions and 0 deletions
|
@ -168,6 +168,9 @@ public:
|
|||
//! Get num blocks.
|
||||
virtual int getNumBlocks() = 0;
|
||||
|
||||
//! Get network local addresses.
|
||||
virtual std::map<CNetAddr, LocalServiceInfo> getNetLocalAddresses() = 0;
|
||||
|
||||
//! Get best block hash.
|
||||
virtual uint256 getBestBlockHash() = 0;
|
||||
|
||||
|
|
|
@ -3533,6 +3533,13 @@ size_t CConnman::GetNodeCount(ConnectionDirection flags) const
|
|||
return nNum;
|
||||
}
|
||||
|
||||
|
||||
std::map<CNetAddr, LocalServiceInfo> CConnman::getNetLocalAddresses() const
|
||||
{
|
||||
LOCK(g_maplocalhost_mutex);
|
||||
return mapLocalHost;
|
||||
}
|
||||
|
||||
uint32_t CConnman::GetMappedAS(const CNetAddr& addr) const
|
||||
{
|
||||
return m_netgroupman.GetMappedAS(addr);
|
||||
|
|
|
@ -1205,6 +1205,7 @@ public:
|
|||
bool AddConnection(const std::string& address, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
|
||||
|
||||
size_t GetNodeCount(ConnectionDirection) const;
|
||||
std::map<CNetAddr, LocalServiceInfo> getNetLocalAddresses() const;
|
||||
uint32_t GetMappedAS(const CNetAddr& addr) const;
|
||||
void GetNodeStats(std::vector<CNodeStats>& vstats) const;
|
||||
bool DisconnectNode(const std::string& node);
|
||||
|
|
|
@ -281,6 +281,13 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
std::map<CNetAddr, LocalServiceInfo> getNetLocalAddresses() override
|
||||
{
|
||||
if (m_context->connman)
|
||||
return m_context->connman->getNetLocalAddresses();
|
||||
else
|
||||
return {};
|
||||
}
|
||||
int getNumBlocks() override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
|
|
|
@ -123,6 +123,13 @@ int64_t ClientModel::getHeaderTipTime() const
|
|||
return cachedBestHeaderTime;
|
||||
}
|
||||
|
||||
|
||||
std::map<CNetAddr, LocalServiceInfo> ClientModel::getNetLocalAddresses() const
|
||||
{
|
||||
return m_node.getNetLocalAddresses();
|
||||
}
|
||||
|
||||
|
||||
int ClientModel::getNumBlocks() const
|
||||
{
|
||||
if (m_cached_num_blocks == -1) {
|
||||
|
|
|
@ -13,12 +13,15 @@
|
|||
#include <sync.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <netaddress.h>
|
||||
|
||||
class BanTableModel;
|
||||
class CBlockIndex;
|
||||
class OptionsModel;
|
||||
class PeerTableModel;
|
||||
class PeerTableSortProxy;
|
||||
enum class SynchronizationState;
|
||||
struct LocalServiceInfo;
|
||||
|
||||
namespace interfaces {
|
||||
class Handler;
|
||||
|
@ -68,6 +71,7 @@ public:
|
|||
|
||||
//! Return number of connections, default is in- and outbound (total)
|
||||
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
|
||||
std::map<CNetAddr, LocalServiceInfo> getNetLocalAddresses() const;
|
||||
int getNumBlocks() const;
|
||||
uint256 getBestBlockHash() EXCLUSIVE_LOCKS_REQUIRED(!m_cached_tip_mutex);
|
||||
int getHeaderTipHeight() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue