Skip to content

Commit 30381ac

Browse files
Merge dashpay#6056: backport: trivial 2024 06 11
fb8a4db Merge bitcoin#26717: test: Improve `check-doc.py` pattern (MarcoFalke) 349cad2 Merge bitcoin#26708: clang-tidy: Fix `modernize-use-nullptr` in headers (MarcoFalke) 6bf786d Merge bitcoin#25735: net: remove useless call to IsReachable() from CConnman::Bind() (fanquake) 012b0b7 Merge bitcoin#24258: test: check localaddresses in getnetworkinfo for nodes with proxy (MarcoFalke) c67f527 Merge bitcoin-core/gui#448: Add helper to load font (Hennadii Stepanov) 8e0abeb Merge bitcoin-core/gui#345: Connection Type Translator Comments (Hennadii Stepanov) 688b66e Merge bitcoin-core/gui#266: Doc: Copyright: Fix embedded font file location (MarcoFalke) Pull request description: ## Issue being fixed or feature implemented Trivial backports ## What was done? ## How Has This Been Tested? Built and ran tests locally; p2p_addr_relay.py fails locally. Not sure why ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK fb8a4db knst: utACK fb8a4db Tree-SHA512: abb9469f25c6d45acea01da6d2b9cb6df94822f61d06f80e3008b32d2522016370a1e0b0c9ff95b92df22c4f227fc40f7765d76f1987eac7603155fe2d894593
2 parents 692a076 + fb8a4db commit 30381ac

File tree

9 files changed

+64
-23
lines changed

9 files changed

+64
-23
lines changed

contrib/debian/copyright

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Files: src/qt/res/icons/proxy.png
3131
Copyright: Cristian Mircea Messel
3232
License: public-domain
3333

34-
Files: src/qt/fonts/RobotoMono-Bold.ttf
34+
Files: src/qt/res/fonts/RobotoMono-Bold.ttf
3535
License: Apache-2.0
3636
Comment: Site: https://fonts.google.com/specimen/Roboto+Mono
3737

src/net.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,12 @@ static constexpr auto FEELER_SLEEP_WINDOW{1s};
105105
/** Used to pass flags to the Bind() function */
106106
enum BindFlags {
107107
BF_NONE = 0,
108-
BF_EXPLICIT = (1U << 0),
109-
BF_REPORT_ERROR = (1U << 1),
108+
BF_REPORT_ERROR = (1U << 0),
110109
/**
111110
* Do not call AddLocal() for our special addresses, e.g., for incoming
112111
* Tor connections, to prevent gossiping them over the network.
113112
*/
114-
BF_DONT_ADVERTISE = (1U << 2),
113+
BF_DONT_ADVERTISE = (1U << 1),
115114
};
116115

117116
#ifndef USE_WAKEUP_PIPE
@@ -3408,9 +3407,6 @@ bool CConnman::Bind(const CService& addr_, unsigned int flags, NetPermissionFlag
34083407
{
34093408
const CService addr{MaybeFlipIPv6toCJDNS(addr_)};
34103409

3411-
if (!(flags & BF_EXPLICIT) && !IsReachable(addr)) {
3412-
return false;
3413-
}
34143410
bilingual_str strError;
34153411
if (!BindListenPort(addr, strError, permissions)) {
34163412
if ((flags & BF_REPORT_ERROR) && clientInterface) {
@@ -3430,13 +3426,13 @@ bool CConnman::InitBinds(const Options& options)
34303426
{
34313427
bool fBound = false;
34323428
for (const auto& addrBind : options.vBinds) {
3433-
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR), NetPermissionFlags::None);
3429+
fBound |= Bind(addrBind, BF_REPORT_ERROR, NetPermissionFlags::None);
34343430
}
34353431
for (const auto& addrBind : options.vWhiteBinds) {
3436-
fBound |= Bind(addrBind.m_service, (BF_EXPLICIT | BF_REPORT_ERROR), addrBind.m_flags);
3432+
fBound |= Bind(addrBind.m_service, BF_REPORT_ERROR, addrBind.m_flags);
34373433
}
34383434
for (const auto& addr_bind : options.onion_binds) {
3439-
fBound |= Bind(addr_bind, BF_EXPLICIT | BF_DONT_ADVERTISE, NetPermissionFlags::None);
3435+
fBound |= Bind(addr_bind, BF_DONT_ADVERTISE, NetPermissionFlags::None);
34403436
}
34413437
if (options.bind_on_any) {
34423438
struct in_addr inaddr_any;

src/qt/bitcoin.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
#include <QApplication>
4949
#include <QDebug>
50-
#include <QFontDatabase>
5150
#include <QLatin1String>
5251
#include <QLibraryInfo>
5352
#include <QLocale>
@@ -577,7 +576,7 @@ int GuiMain(int argc, char* argv[])
577576
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
578577

579578
BitcoinApplication app;
580-
QFontDatabase::addApplicationFont(":/fonts/monospace");
579+
GUIUtil::LoadFont(QStringLiteral(":/fonts/monospace"));
581580

582581
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
583582
// Command-line options take precedence:

src/qt/guiutil.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,12 @@ bool hasEntryData(const QAbstractItemView *view, int column, int role)
493493
return !selection.at(0).data(role).toString().isEmpty();
494494
}
495495

496+
void LoadFont(const QString& file_name)
497+
{
498+
const int id = QFontDatabase::addApplicationFont(file_name);
499+
assert(id != -1);
500+
}
501+
496502
QString getDefaultDataDirectory()
497503
{
498504
return PathToQString(GetDefaultDataDir());
@@ -1673,14 +1679,26 @@ QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction
16731679
{
16741680
QString prefix;
16751681
if (prepend_direction) {
1676-
prefix = (conn_type == ConnectionType::INBOUND) ? QObject::tr("Inbound") : QObject::tr("Outbound") + " ";
1682+
prefix = (conn_type == ConnectionType::INBOUND) ?
1683+
/*: An inbound connection from a peer. An inbound connection
1684+
is a connection initiated by a peer. */
1685+
QObject::tr("Inbound") :
1686+
/*: An outbound connection to a peer. An outbound connection
1687+
is a connection initiated by us. */
1688+
QObject::tr("Outbound") + " ";
16771689
}
16781690
switch (conn_type) {
16791691
case ConnectionType::INBOUND: return prefix;
1692+
//: Peer connection type that relays all network information.
16801693
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
1694+
/*: Peer connection type that relays network information about
1695+
blocks and not transactions or addresses. */
16811696
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
1697+
//: Peer connection type established manually through one of several methods.
16821698
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
1699+
//: Short-lived peer connection type that tests the aliveness of known addresses.
16831700
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
1701+
//: Short-lived peer connection type that solicits known addresses from a peer.
16841702
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
16851703
} // no default case, so the compiler can warn about missing cases
16861704
assert(false);

src/qt/guiutil.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ namespace GUIUtil
172172

173173
void setClipboard(const QString& str);
174174

175+
/**
176+
* Loads the font from the file specified by file_name, aborts if it fails.
177+
*/
178+
void LoadFont(const QString& file_name);
179+
175180
/**
176181
* Determine default data directory for operating system.
177182
*/

src/qt/rpcconsole.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,28 @@ RPCConsole::RPCConsole(interfaces::Node& node, QWidget* parent, Qt::WindowFlags
503503

504504
constexpr QChar nonbreaking_hyphen(8209);
505505
const std::vector<QString> CONNECTION_TYPE_DOC{
506+
//: Explanatory text for an inbound peer connection.
506507
tr("Inbound: initiated by peer"),
508+
/*: Explanatory text for an outbound peer connection that
509+
relays all network information. This is the default behavior for
510+
outbound connections. */
507511
tr("Outbound Full Relay: default"),
512+
/*: Explanatory text for an outbound peer connection that relays
513+
network information about blocks and not transactions or addresses. */
508514
tr("Outbound Block Relay: does not relay transactions or addresses"),
515+
/*: Explanatory text for an outbound peer connection that was
516+
established manually through one of several methods. The numbered
517+
arguments are stand-ins for the methods available to establish
518+
manual connections. */
509519
tr("Outbound Manual: added using RPC %1 or %2/%3 configuration options")
510520
.arg("addnode")
511521
.arg(QString(nonbreaking_hyphen) + "addnode")
512522
.arg(QString(nonbreaking_hyphen) + "connect"),
523+
/*: Explanatory text for a short-lived outbound peer connection that
524+
is used to test the aliveness of known addresses. */
513525
tr("Outbound Feeler: short-lived, for testing addresses"),
526+
/*: Explanatory text for a short-lived outbound peer connection that is used
527+
to request addresses from a peer. */
514528
tr("Outbound Address Fetch: short-lived, for soliciting addresses")};
515529
const QString list{"<ul><li>" + Join(CONNECTION_TYPE_DOC, QString("</li><li>")) + "</li></ul>"};
516530
ui->peerConnectionTypeLabel->setToolTip(ui->peerConnectionTypeLabel->toolTip().arg(list));

src/tinyformat.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,9 @@ class FormatArg
508508
{
509509
public:
510510
FormatArg()
511-
: m_value(NULL),
512-
m_formatImpl(NULL),
513-
m_toIntImpl(NULL)
511+
: m_value(nullptr),
512+
m_formatImpl(nullptr),
513+
m_toIntImpl(nullptr)
514514
{ }
515515

516516
template<typename T>
@@ -1005,7 +1005,8 @@ class FormatListN : public FormatList
10051005
// Special 0-arg version - MSVC says zero-sized C array in struct is nonstandard
10061006
template<> class FormatListN<0> : public FormatList
10071007
{
1008-
public: FormatListN() : FormatList(0, 0) {}
1008+
public:
1009+
FormatListN() : FormatList(nullptr, 0) {}
10091010
};
10101011

10111012
} // namespace detail

test/functional/feature_proxy.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,15 @@ def networks_dict(d):
237237
return r
238238

239239
self.log.info("Test RPC getnetworkinfo")
240-
n0 = networks_dict(self.nodes[0].getnetworkinfo())
240+
nodes_network_info = []
241+
242+
self.log.debug("Test that setting -proxy disables local address discovery, i.e. -discover=0")
243+
for node in self.nodes:
244+
network_info = node.getnetworkinfo()
245+
assert_equal(network_info["localaddresses"], [])
246+
nodes_network_info.append(network_info)
247+
248+
n0 = networks_dict(nodes_network_info[0])
241249
assert_equal(NETWORKS, n0.keys())
242250
for net in NETWORKS:
243251
if net == NET_I2P:
@@ -252,7 +260,7 @@ def networks_dict(d):
252260
assert_equal(n0['i2p']['reachable'], False)
253261
assert_equal(n0['cjdns']['reachable'], False)
254262

255-
n1 = networks_dict(self.nodes[1].getnetworkinfo())
263+
n1 = networks_dict(nodes_network_info[1])
256264
assert_equal(NETWORKS, n1.keys())
257265
for net in ['ipv4', 'ipv6']:
258266
assert_equal(n1[net]['proxy'], f'{self.conf1.addr[0]}:{self.conf1.addr[1]}')
@@ -264,7 +272,7 @@ def networks_dict(d):
264272
assert_equal(n1['i2p']['proxy_randomize_credentials'], False)
265273
assert_equal(n1['i2p']['reachable'], True)
266274

267-
n2 = networks_dict(self.nodes[2].getnetworkinfo())
275+
n2 = networks_dict(nodes_network_info[2])
268276
assert_equal(NETWORKS, n2.keys())
269277
proxy = f'{self.conf2.addr[0]}:{self.conf2.addr[1]}'
270278
for net in NETWORKS:
@@ -281,7 +289,7 @@ def networks_dict(d):
281289
assert_equal(n2['cjdns']['reachable'], False)
282290

283291
if self.have_ipv6:
284-
n3 = networks_dict(self.nodes[3].getnetworkinfo())
292+
n3 = networks_dict(nodes_network_info[3])
285293
assert_equal(NETWORKS, n3.keys())
286294
proxy = f'[{self.conf3.addr[0]}]:{self.conf3.addr[1]}'
287295
for net in NETWORKS:
@@ -292,7 +300,7 @@ def networks_dict(d):
292300
assert_equal(n3['i2p']['reachable'], False)
293301
assert_equal(n3['cjdns']['reachable'], False)
294302

295-
n4 = networks_dict(self.nodes[4].getnetworkinfo())
303+
n4 = networks_dict(nodes_network_info[4])
296304
assert_equal(NETWORKS, n4.keys())
297305
for net in NETWORKS:
298306
if net == NET_I2P:

test/lint/check-doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
FOLDER_GREP = 'src'
1717
FOLDER_TEST = 'src/test/'
18-
REGEX_ARG = r'(?:ForceSet|SoftSet|Get|Is)(?:Bool)?Args?(?:Set)?\("(-[^"]+)"'
18+
REGEX_ARG = r'\b(?:GetArg|GetArgs|GetBoolArg|GetIntArg|GetPathArg|IsArgSet|get_net)\("(-[^"]+)"'
1919
REGEX_DOC = r'AddArg\("(-[^"=]+?)(?:=|")'
2020
CMD_ROOT_DIR = '$(git rev-parse --show-toplevel)/{}'.format(FOLDER_GREP)
2121
CMD_GREP_ARGS = r"git grep --perl-regexp '{}' -- {} ':(exclude){}'".format(REGEX_ARG, CMD_ROOT_DIR, FOLDER_TEST)

0 commit comments

Comments
 (0)