Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trivial: remove boost::{function, lexical_cast} usage, backport bitcoin#25550, #24624, #24406, cleanup some gArgs usage in init #5986

Merged
merged 6 commits into from
Apr 23, 2024
24 changes: 0 additions & 24 deletions doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,27 +313,3 @@ or building and depending on a local version of Berkeley DB 4.8. The readily ava
`--with-incompatible-bdb` according to the [PKGBUILD](https://projects.archlinux.org/svntogit/community.git/tree/bitcoin/trunk/PKGBUILD).
As mentioned above, when maintaining portability of the wallet between the standard Dash Core distributions and independently built
node software is desired, Berkeley DB 4.8 must be used.


ARM Cross-compilation
-------------------
These steps can be performed on, for example, an Ubuntu VM. The depends system
will also work on other Linux distributions, however the commands for
installing the toolchain will be different.

Make sure you install the build requirements mentioned above.
Then, install the toolchain and curl:

sudo apt-get install g++-arm-linux-gnueabihf curl

To build executables for ARM:

cd depends
make HOST=arm-linux-gnueabihf NO_QT=1
cd ..
./autogen.sh
CONFIG_SITE=$PWD/depends/arm-linux-gnueabihf/share/config.site ./configure --enable-reduce-exports LDFLAGS=-static-libstdc++
make


For further documentation on the depends system see [README.md](../depends/README.md) in the depends directory.
32 changes: 0 additions & 32 deletions src/bench/string_cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <util/strencodings.h>
#include <util/string.h>

#include <boost/lexical_cast.hpp>
#include <string>

template <typename T>
Expand All @@ -25,21 +24,6 @@ static void int_atoi(benchmark::Bench& bench)
});
}

static void int_lexical_cast(benchmark::Bench& bench)
{
bench.run([&] {
boost::lexical_cast<int>("1");
});
}

static void strings_1_lexical_cast(benchmark::Bench& bench)
{
int i{0};
bench.run([&] {
boost::lexical_cast<std::string>(++i);
});
}

static void strings_1_numberToString(benchmark::Bench& bench)
{
int i{0};
Expand All @@ -56,19 +40,6 @@ static void strings_1_tostring(benchmark::Bench& bench)
});
}

static void strings_2_multi_lexical_cast(benchmark::Bench& bench)
{
int i{0};
bench.run([&] { static_cast<void>(
boost::lexical_cast<std::string>(i) +
boost::lexical_cast<std::string>(i+1) +
boost::lexical_cast<std::string>(i+2) +
boost::lexical_cast<std::string>(i+3) +
boost::lexical_cast<std::string>(i+4));
++i;
});
}

static void strings_2_multi_numberToString(benchmark::Bench& bench)
{
int i{0};
Expand Down Expand Up @@ -97,11 +68,8 @@ static void strings_2_strptintf(benchmark::Bench& bench)
}

BENCHMARK(int_atoi);
BENCHMARK(int_lexical_cast);
BENCHMARK(strings_1_lexical_cast);
BENCHMARK(strings_1_numberToString);
BENCHMARK(strings_1_tostring);
BENCHMARK(strings_2_multi_lexical_cast);
BENCHMARK(strings_2_multi_numberToString);
BENCHMARK(strings_2_multi_tostring);
BENCHMARK(strings_2_strptintf);
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ void SetupServerArgs(NodeContext& node)
argsman.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-socketevents=<mode>", "Socket events mode, which must be one of 'select', 'poll', 'epoll' or 'kqueue', depending on your system (default: Linux - 'epoll', FreeBSD/Apple - 'kqueue', Windows - 'select')", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_BOOL, OptionsCategory::CONNECTION);
argsman.AddArg("-networkactive", "Enable all P2P network activity (default: 1). Can be changed by the setnetworkactive RPC command", ArgsManager::ALLOW_BOOL, OptionsCategory::CONNECTION);
argsman.AddArg("-timeout=<n>", strprintf("Specify socket connection timeout in milliseconds. If an initial attempt to connect is unsuccessful after this amount of time, drop it (minimum: 1, default: %d)", DEFAULT_CONNECT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-torcontrol=<ip>:<port>", strprintf("Tor control port to use if onion listening enabled (default: %s)", DEFAULT_TOR_CONTROL), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-torpassword=<pass>", "Tor control port password (default: empty)", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::CONNECTION);
Expand Down Expand Up @@ -1663,7 +1663,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
assert(!node.banman);
node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
assert(!node.connman);
node.connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), *node.addrman, gArgs.GetBoolArg("-networkactive", true));
node.connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), *node.addrman, args.GetBoolArg("-networkactive", true));

assert(!node.fee_estimator);
// Don't initialize fee estimation with old data if we don't relay transactions,
Expand Down
7 changes: 4 additions & 3 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <QComboBox>
#include <QDateTime>
#include <QDragEnterEvent>
#include <QKeySequence>
#include <QListWidget>
#include <QMenu>
#include <QMenuBar>
Expand Down Expand Up @@ -373,7 +374,7 @@ void BitcoinGUI::createActions()

quitAction = new QAction(tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(tr("&About %1").arg(PACKAGE_NAME), this);
aboutAction->setStatusTip(tr("Show information about %1").arg(PACKAGE_NAME));
Expand Down Expand Up @@ -463,7 +464,7 @@ void BitcoinGUI::createActions()
showCoinJoinHelpAction->setStatusTip(tr("Show the %1 basic information").arg(strCoinJoinName));

m_mask_values_action = new QAction(tr("&Discreet mode"), this);
m_mask_values_action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D));
m_mask_values_action->setShortcut(QKeySequence(tr("Ctrl+Shift+D")));
m_mask_values_action->setStatusTip(tr("Mask the values in the Overview tab"));
m_mask_values_action->setCheckable(true);

Expand Down Expand Up @@ -606,7 +607,7 @@ void BitcoinGUI::createMenuBar()
QMenu* window_menu = appMenuBar->addMenu(tr("&Window"));

QAction* minimize_action = window_menu->addAction(tr("Minimize"));
minimize_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
minimize_action->setShortcut(QKeySequence(tr("Ctrl+M")));
connect(minimize_action, &QAction::triggered, [] {
QApplication::activeWindow()->showMinimized();
});
Expand Down
5 changes: 3 additions & 2 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <QGuiApplication>
#include <QJsonObject>
#include <QKeyEvent>
#include <QKeySequence>
#include <QLatin1String>
#include <QLineEdit>
#include <QList>
Expand Down Expand Up @@ -613,7 +614,7 @@ void bringToFront(QWidget* w)

void handleCloseWindowShortcut(QWidget* w)
{
QObject::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), w), &QShortcut::activated, w, &QWidget::close);
QObject::connect(new QShortcut(QKeySequence(QObject::tr("Ctrl+W")), w), &QShortcut::activated, w, &QWidget::close);
}

void openDebugLogfile()
Expand Down Expand Up @@ -1618,7 +1619,7 @@ void updateButtonGroupShortcuts(QButtonGroup* buttonGroup)
int nKey = 0;
for (auto button : buttonGroup->buttons()) {
if (button->isVisible()) {
button->setShortcut(QKeySequence(modifier + Qt::Key_1 + nKey++));
button->setShortcut(QKeySequence(static_cast<int>(modifier) | static_cast<int>(Qt::Key_1) | nKey++));
} else {
button->setShortcut(QKeySequence());
}
Expand Down
11 changes: 6 additions & 5 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <QFontDatabase>
#include <QDateTime>
#include <QKeyEvent>
#include <QKeySequence>
#include <QMenu>
#include <QMessageBox>
#include <QScreen>
Expand Down Expand Up @@ -1459,11 +1460,11 @@ QString RPCConsole::tabTitle(TabTypes tab_type) const
QKeySequence RPCConsole::tabShortcut(TabTypes tab_type) const
{
switch (tab_type) {
case TabTypes::INFO: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I);
case TabTypes::CONSOLE: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C);
case TabTypes::GRAPH: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
case TabTypes::PEERS: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P);
case TabTypes::REPAIR: return QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R);
case TabTypes::INFO: return QKeySequence(tr("Ctrl+Shift+I"));
case TabTypes::CONSOLE: return QKeySequence(tr("Ctrl+Shift+C"));
case TabTypes::GRAPH: return QKeySequence(tr("Ctrl+Shift+G"));
case TabTypes::PEERS: return QKeySequence(tr("Ctrl+Shift+P"));
case TabTypes::REPAIR: return QKeySequence(tr("Ctrl+Shift+R"));
} // no default case, so the compiler can warn about missing cases

assert(false);
Expand Down
4 changes: 1 addition & 3 deletions src/qt/trafficgraphwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include <qt/trafficgraphdata.h>

#include <boost/function.hpp>

#include <QWidget>
#include <QQueue>

Expand Down Expand Up @@ -37,7 +35,7 @@ public Q_SLOTS:
void clear();

private:
typedef boost::function<float(const TrafficSample&)> SampleChooser;
typedef std::function<float(const TrafficSample&)> SampleChooser;
kwvg marked this conversation as resolved.
Show resolved Hide resolved
void paintPath(QPainterPath &path, const TrafficGraphData::SampleQueue &queue, SampleChooser chooser);

QTimer *timer;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ QWidget *TransactionView::createDateRangeWidget()
QSettings settings;

dateRangeWidget = new QFrame();
dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
dateRangeWidget->setFrameStyle(static_cast<int>(QFrame::Panel) | static_cast<int>(QFrame::Raised));
dateRangeWidget->setContentsMargins(1,1,1,1);
QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget);
layout->setContentsMargins(0,0,0,0);
Expand Down
2 changes: 1 addition & 1 deletion src/test/fuzz/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class CAddrManDeterministic : public CAddrMan
* - vvNew entries refer to the same addresses
* - vvTried entries refer to the same addresses
*/
bool operator==(const CAddrManDeterministic& other)
bool operator==(const CAddrManDeterministic& other) const
{
LOCK2(cs, other.cs);

Expand Down
12 changes: 6 additions & 6 deletions src/test/serialize_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ class CSerializeMethodsTestSingle
READWRITE(obj.txval);
}

bool operator==(const CSerializeMethodsTestSingle& rhs)
bool operator==(const CSerializeMethodsTestSingle& rhs) const
{
return intval == rhs.intval && \
boolval == rhs.boolval && \
stringval == rhs.stringval && \
strcmp(charstrval, rhs.charstrval) == 0 && \
*txval == *rhs.txval;
return intval == rhs.intval &&
boolval == rhs.boolval &&
stringval == rhs.stringval &&
strcmp(charstrval, rhs.charstrval) == 0 &&
*txval == *rhs.txval;
}
};

Expand Down
2 changes: 0 additions & 2 deletions test/lint/lint-includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ EXPECTED_BOOST_INCLUDES=(
boost/date_time/posix_time/posix_time.hpp
boost/filesystem.hpp
boost/filesystem/fstream.hpp
boost/function.hpp
boost/lexical_cast.hpp
boost/multi_index/hashed_index.hpp
boost/multi_index/ordered_index.hpp
boost/multi_index/sequenced_index.hpp
Expand Down
Loading