mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#22782: Remove unused MaybeSetAddrName
This commit is contained in:
parent
2b65526818
commit
bf98ad6a42
@ -1336,7 +1336,7 @@ void CDKGSession::RelayInvToParticipants(const CInv& inv) const
|
||||
if (pnode->GetVerifiedProRegTxHash().IsNull()) {
|
||||
logger.Batch("node[%d:%s] not mn",
|
||||
pnode->GetId(),
|
||||
pnode->GetAddrName());
|
||||
pnode->m_addr_name);
|
||||
} else if (relayMembers.count(pnode->GetVerifiedProRegTxHash()) == 0) {
|
||||
ss2 << pnode->GetVerifiedProRegTxHash().ToString().substr(0, 4) << " | ";
|
||||
}
|
||||
|
33
src/net.cpp
33
src/net.cpp
@ -364,7 +364,7 @@ CNode* CConnman::FindNode(const std::string& addrName, bool fExcludeDisconnectin
|
||||
if (fExcludeDisconnecting && pnode->fDisconnect) {
|
||||
continue;
|
||||
}
|
||||
if (pnode->GetAddrName() == addrName) {
|
||||
if (pnode->m_addr_name == addrName) {
|
||||
return pnode;
|
||||
}
|
||||
}
|
||||
@ -457,14 +457,10 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
||||
return nullptr;
|
||||
}
|
||||
// It is possible that we already have a connection to the IP/port pszDest resolved to.
|
||||
// In that case, drop the connection that was just created, and return the existing CNode instead.
|
||||
// Also store the name we used to connect in that CNode, so that future FindNode() calls to that
|
||||
// name catch this early.
|
||||
// In that case, drop the connection that was just created.
|
||||
LOCK(cs_vNodes);
|
||||
CNode* pnode = FindNode(static_cast<CService>(addrConnect));
|
||||
if (pnode)
|
||||
{
|
||||
pnode->MaybeSetAddrName(std::string(pszDest));
|
||||
if (pnode) {
|
||||
LogPrintf("Failed to open new connection, already connected\n");
|
||||
return nullptr;
|
||||
}
|
||||
@ -608,19 +604,8 @@ std::string ConnectionTypeAsString(ConnectionType conn_type)
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::string CNode::GetAddrName() const {
|
||||
LOCK(cs_addrName);
|
||||
return addrName;
|
||||
}
|
||||
|
||||
void CNode::MaybeSetAddrName(const std::string& addrNameIn) {
|
||||
LOCK(cs_addrName);
|
||||
if (addrName.empty()) {
|
||||
addrName = addrNameIn;
|
||||
}
|
||||
}
|
||||
|
||||
CService CNode::GetAddrLocal() const {
|
||||
CService CNode::GetAddrLocal() const
|
||||
{
|
||||
LOCK(cs_addrLocal);
|
||||
return addrLocal;
|
||||
}
|
||||
@ -660,7 +645,7 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
|
||||
X(nLastBlockTime);
|
||||
X(nTimeConnected);
|
||||
X(nTimeOffset);
|
||||
stats.addrName = GetAddrName();
|
||||
X(m_addr_name);
|
||||
X(nVersion);
|
||||
{
|
||||
LOCK(cs_SubVer);
|
||||
@ -2629,7 +2614,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo() const
|
||||
if (pnode->addr.IsValid()) {
|
||||
mapConnected[pnode->addr] = pnode->IsInboundConn();
|
||||
}
|
||||
std::string addrName = pnode->GetAddrName();
|
||||
std::string addrName{pnode->m_addr_name};
|
||||
if (!addrName.empty()) {
|
||||
mapConnectedByName[std::move(addrName)] = std::make_pair(pnode->IsInboundConn(), static_cast<const CService&>(pnode->addr));
|
||||
}
|
||||
@ -4018,6 +4003,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const
|
||||
: nTimeConnected(GetTimeSeconds()),
|
||||
addr(addrIn),
|
||||
addrBind(addrBindIn),
|
||||
m_addr_name{addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn},
|
||||
m_inbound_onion(inbound_onion),
|
||||
nKeyedNetGroup(nKeyedNetGroupIn),
|
||||
id(idIn),
|
||||
@ -4027,14 +4013,13 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const
|
||||
{
|
||||
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
|
||||
hSocket = hSocketIn;
|
||||
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
|
||||
|
||||
for (const std::string &msg : getAllNetMessageTypes())
|
||||
mapRecvBytesPerMsgCmd[msg] = 0;
|
||||
mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0;
|
||||
|
||||
if (fLogIPs) {
|
||||
LogPrint(BCLog::NET, "Added connection to %s peer=%d\n", addrName, id);
|
||||
LogPrint(BCLog::NET, "Added connection to %s peer=%d\n", m_addr_name, id);
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "Added connection peer=%d\n", id);
|
||||
}
|
||||
|
11
src/net.h
11
src/net.h
@ -281,7 +281,7 @@ public:
|
||||
int64_t nLastBlockTime;
|
||||
int64_t nTimeConnected;
|
||||
int64_t nTimeOffset;
|
||||
std::string addrName;
|
||||
std::string m_addr_name;
|
||||
int nVersion;
|
||||
std::string cleanSubVer;
|
||||
bool fInbound;
|
||||
@ -471,6 +471,7 @@ public:
|
||||
const CAddress addr;
|
||||
// Bind address of our side of the connection
|
||||
const CAddress addrBind;
|
||||
const std::string m_addr_name;
|
||||
//! Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
|
||||
const bool m_inbound_onion;
|
||||
std::atomic<int> nNumWarningsSkipped{0};
|
||||
@ -687,11 +688,6 @@ public:
|
||||
return nLocalServices;
|
||||
}
|
||||
|
||||
std::string GetAddrName() const;
|
||||
//! Sets the addrName only if it was not previously set
|
||||
void MaybeSetAddrName(const std::string& addrNameIn);
|
||||
|
||||
|
||||
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
|
||||
|
||||
/** A ping-pong round trip has completed successfully. Update latest and minimum ping times. */
|
||||
@ -769,9 +765,6 @@ private:
|
||||
|
||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||
|
||||
mutable RecursiveMutex cs_addrName;
|
||||
std::string addrName GUARDED_BY(cs_addrName);
|
||||
|
||||
// Our address, as reported by the peer
|
||||
CService addrLocal GUARDED_BY(cs_addrLocal);
|
||||
mutable RecursiveMutex cs_addrLocal;
|
||||
|
@ -28,7 +28,7 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
|
||||
case PeerTableModel::NetNodeId:
|
||||
return pLeft->nodeid < pRight->nodeid;
|
||||
case PeerTableModel::Address:
|
||||
return pLeft->addrName.compare(pRight->addrName) < 0;
|
||||
return pLeft->m_addr_name.compare(pRight->m_addr_name) < 0;
|
||||
case PeerTableModel::Network:
|
||||
return pLeft->m_network < pRight->m_network;
|
||||
case PeerTableModel::Ping:
|
||||
@ -163,7 +163,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
|
||||
return (qint64)rec->nodeStats.nodeid;
|
||||
case Address:
|
||||
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
|
||||
return QString(rec->nodeStats.fInbound ? "↓ " : "↑ ") + QString::fromStdString(rec->nodeStats.addrName);
|
||||
return QString(rec->nodeStats.fInbound ? "↓ " : "↑ ") + QString::fromStdString(rec->nodeStats.m_addr_name);
|
||||
case Network:
|
||||
return GUIUtil::NetworkToQString(rec->nodeStats.m_network);
|
||||
case Ping:
|
||||
|
@ -1230,7 +1230,7 @@ void RPCConsole::updateDetailWidget()
|
||||
}
|
||||
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row());
|
||||
// update the detail ui with latest node information
|
||||
QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
|
||||
QString peerAddrDetails(QString::fromStdString(stats->nodeStats.m_addr_name) + " ");
|
||||
peerAddrDetails += tr("(peer id: %1)").arg(QString::number(stats->nodeStats.nodeid));
|
||||
if (!stats->nodeStats.addrLocal.empty())
|
||||
peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
|
||||
|
@ -200,7 +200,7 @@ static RPCHelpMan getpeerinfo()
|
||||
CNodeStateStats statestats;
|
||||
bool fStateStats = peerman.GetNodeStateStats(stats.nodeid, statestats);
|
||||
obj.pushKV("id", stats.nodeid);
|
||||
obj.pushKV("addr", stats.addrName);
|
||||
obj.pushKV("addr", stats.m_addr_name);
|
||||
if (stats.addrBind.IsValid()) {
|
||||
obj.pushKV("addrbind", stats.addrBind.ToString());
|
||||
}
|
||||
|
@ -40,9 +40,6 @@ FUZZ_TARGET_INIT(net, initialize_net)
|
||||
CConnman connman{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>(), addrman};
|
||||
node.CloseSocketDisconnect(&connman);
|
||||
},
|
||||
[&] {
|
||||
node.MaybeSetAddrName(fuzzed_data_provider.ConsumeRandomLengthString(32));
|
||||
},
|
||||
[&] {
|
||||
const std::vector<bool> asmap = ConsumeRandomLengthBitVector(fuzzed_data_provider);
|
||||
if (!SanityCheckASMap(asmap)) {
|
||||
@ -75,7 +72,6 @@ FUZZ_TARGET_INIT(net, initialize_net)
|
||||
}
|
||||
|
||||
(void)node.GetAddrLocal();
|
||||
(void)node.GetAddrName();
|
||||
(void)node.GetId();
|
||||
(void)node.GetLocalNonce();
|
||||
(void)node.GetLocalServices();
|
||||
|
Loading…
Reference in New Issue
Block a user