Merge bitcoin/bitcoin#22732: net: use m_client_interface rather than uiInterface

d8ba6327b2 scripted-diff: replace clientInterface with m_client_interface in net (fanquake)
f68c6cebe6 net: use clientInterface rather than uiInterface (fanquake)

Pull request description:

  First commit fixes two cases where we were using `uiInterface`, rather than `clientInterface`.
  Second commit renames `clientInterface` to `m_client_interface`, to match banman.

ACKs for top commit:
  hebasto:
    ACK d8ba6327b2, verified that `uiInterface` is replaced in all sites.
  Zero-1729:
    crACK d8ba6327b2

Tree-SHA512: 9c893d8799b0bc7737836c16e11b77b6f9dffa31041ec6678e63cad958ea06da09a841b99cc61c1b4d9f6f4f1be397ca5a8d2fb2fb7ab08c9437043f8a57c3dc
This commit is contained in:
fanquake committed 2021-08-18 20:12:39 +08:00
commit e35c4a3d80
2 files changed
+19 -14

No files matched your search

+17 -12
View File
@@ -1304,8 +1304,9 @@ void CConnman::NotifyNumConnectionsChanged()
} }
if(vNodesSize != nPrevNodeCount) { if(vNodesSize != nPrevNodeCount) {
nPrevNodeCount = vNodesSize; nPrevNodeCount = vNodesSize;
if(clientInterface) if (m_client_interface) {
clientInterface->NotifyNumConnectionsChanged(vNodesSize); m_client_interface->NotifyNumConnectionsChanged(vNodesSize);
}
} }
} }
@@ -2448,7 +2449,9 @@ void CConnman::SetNetworkActive(bool active)
fNetworkActive = active; fNetworkActive = active;
uiInterface.NotifyNetworkActiveChanged(fNetworkActive); if (m_client_interface) {
m_client_interface->NotifyNetworkActiveChanged(fNetworkActive);
}
} }
CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In, CAddrMan& addrman_in, bool network_active) CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In, CAddrMan& addrman_in, bool network_active)
@@ -2473,8 +2476,8 @@ bool CConnman::Bind(const CService &addr, unsigned int flags, NetPermissionFlags
} }
bilingual_str strError; bilingual_str strError;
if (!BindListenPort(addr, strError, permissions)) { if (!BindListenPort(addr, strError, permissions)) {
if ((flags & BF_REPORT_ERROR) && clientInterface) { if ((flags & BF_REPORT_ERROR) && m_client_interface) {
clientInterface->ThreadSafeMessageBox(strError, "", CClientUIInterface::MSG_ERROR); m_client_interface->ThreadSafeMessageBox(strError, "", CClientUIInterface::MSG_ERROR);
} }
return false; return false;
} }
@@ -2513,8 +2516,8 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
Init(connOptions); Init(connOptions);
if (fListen && !InitBinds(connOptions)) { if (fListen && !InitBinds(connOptions)) {
if (clientInterface) { if (m_client_interface) {
clientInterface->ThreadSafeMessageBox( m_client_interface->ThreadSafeMessageBox(
_("Failed to listen on any port. Use -listen=0 if you want this."), _("Failed to listen on any port. Use -listen=0 if you want this."),
"", CClientUIInterface::MSG_ERROR); "", CClientUIInterface::MSG_ERROR);
} }
@@ -2531,8 +2534,8 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
AddAddrFetch(strDest); AddAddrFetch(strDest);
} }
if (clientInterface) { if (m_client_interface) {
clientInterface->InitMessage(_("Loading P2P addresses…").translated); m_client_interface->InitMessage(_("Loading P2P addresses…").translated);
} }
// Load addresses from peers.dat // Load addresses from peers.dat
int64_t nStart = GetTimeMillis(); int64_t nStart = GetTimeMillis();
@@ -2556,7 +2559,9 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
LogPrintf("%i block-relay-only anchors will be tried for connections.\n", m_anchors.size()); LogPrintf("%i block-relay-only anchors will be tried for connections.\n", m_anchors.size());
} }
uiInterface.InitMessage(_("Starting network threads…").translated); if (m_client_interface) {
m_client_interface->InitMessage(_("Starting network threads…").translated);
}
fAddressesInitialized = true; fAddressesInitialized = true;
@@ -2594,8 +2599,8 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
threadOpenAddedConnections = std::thread(&util::TraceThread, "addcon", [this] { ThreadOpenAddedConnections(); }); threadOpenAddedConnections = std::thread(&util::TraceThread, "addcon", [this] { ThreadOpenAddedConnections(); });
if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) { if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) {
if (clientInterface) { if (m_client_interface) {
clientInterface->ThreadSafeMessageBox( m_client_interface->ThreadSafeMessageBox(
_("Cannot provide specific connections and have addrman find outgoing connections at the same."), _("Cannot provide specific connections and have addrman find outgoing connections at the same."),
"", CClientUIInterface::MSG_ERROR); "", CClientUIInterface::MSG_ERROR);
} }
+2 -2
View File
@@ -787,7 +787,7 @@ public:
nMaxAddnode = connOptions.nMaxAddnode; nMaxAddnode = connOptions.nMaxAddnode;
nMaxFeeler = connOptions.nMaxFeeler; nMaxFeeler = connOptions.nMaxFeeler;
m_max_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + nMaxFeeler; m_max_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + nMaxFeeler;
clientInterface = connOptions.uiInterface; m_client_interface = connOptions.uiInterface;
m_banman = connOptions.m_banman; m_banman = connOptions.m_banman;
m_msgproc = connOptions.m_msgproc; m_msgproc = connOptions.m_msgproc;
nSendBufferMaxSize = connOptions.nSendBufferMaxSize; nSendBufferMaxSize = connOptions.nSendBufferMaxSize;
@@ -1126,7 +1126,7 @@ private:
int nMaxFeeler; int nMaxFeeler;
int m_max_outbound; int m_max_outbound;
bool m_use_addrman_outgoing; bool m_use_addrman_outgoing;
CClientUIInterface* clientInterface; CClientUIInterface* m_client_interface;
NetEventsInterface* m_msgproc; NetEventsInterface* m_msgproc;
/** Pointer to this node's banman. May be nullptr - check existence before dereferencing. */ /** Pointer to this node's banman. May be nullptr - check existence before dereferencing. */
BanMan* m_banman; BanMan* m_banman;