Return mapped AS in RPC call getpeerinfo

If ASN bucketing is used, return a corresponding AS
used in bucketing for a given peer.
This commit is contained in:
Gleb Naumenko
2019-12-24 13:26:46 -05:00
parent ec45646de9
commit e4658aa8ea
5 changed files with 62 additions and 35 deletions

View File

@@ -493,12 +493,13 @@ void CNode::SetAddrLocal(const CService& addrLocalIn) {
#undef X
#define X(name) stats.name = name
void CNode::copyStats(CNodeStats &stats)
void CNode::copyStats(CNodeStats &stats, std::vector<bool> &m_asmap)
{
stats.nodeid = this->GetId();
X(nServices);
X(addr);
X(addrBind);
stats.m_mapped_as = addr.GetMappedAS(m_asmap);
if (m_tx_relay != nullptr) {
LOCK(m_tx_relay->cs_filter);
stats.fRelayTxes = m_tx_relay->fRelayTxes;
@@ -2491,7 +2492,7 @@ void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)
vstats.reserve(vNodes.size());
for (CNode* pnode : vNodes) {
vstats.emplace_back();
pnode->copyStats(vstats.back());
pnode->copyStats(vstats.back(), addrman.m_asmap);
}
}