Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
98473af
Add src/interface/README.md
ryanofsky Mar 27, 2017
e709f5a
Remove direct bitcoin calls from qt/bitcoin.cpp
ryanofsky Apr 17, 2017
f45e095
Remove direct bitcoin calls from qt/optionsmodel.cpp
ryanofsky Apr 17, 2017
50f1a62
Remove direct bitcoin calls from qt/bitcoingui.cpp
ryanofsky Apr 17, 2017
2fdf3d8
Remove direct bitcoin calls from qt/utilitydialog.cpp
ryanofsky Apr 17, 2017
2856f46
Remove direct bitcoin calls from qt/splashscreen.cpp
ryanofsky Apr 17, 2017
7fe386a
Remove direct bitcoin calls from qt/clientmodel.cpp
ryanofsky Apr 17, 2017
5512eca
Remove direct bitcoin calls from qt/intro.cpp
ryanofsky Apr 17, 2017
59cec79
Remove direct bitcoin calls from qt/peertablemodel.cpp
ryanofsky Apr 17, 2017
80286d7
Remove direct bitcoin calls from qt/bantablemodel.cpp
ryanofsky Apr 17, 2017
a19c1f8
Remove direct bitcoin calls from qt/rpcconsole.cpp
ryanofsky Apr 17, 2017
6298c97
Remove direct bitcoin calls from qt/optionsdialog.cpp
ryanofsky Apr 17, 2017
bda6fc4
Remove most direct bitcoin calls from qt/walletmodel.cpp
ryanofsky Apr 17, 2017
7bb2d25
Remove direct bitcoin calls from qt/coincontroldialog.cpp
ryanofsky Apr 17, 2017
50f7d66
Remove direct bitcoin calls from qt/addresstablemodel.cpp
ryanofsky Apr 18, 2017
b2f7e1d
Remove direct bitcoin calls from qt/paymentserver.cpp
ryanofsky Mar 23, 2018
155324e
Remove direct bitcoin calls from qt transaction table files
ryanofsky Apr 18, 2017
e4e00cb
Remove direct bitcoin access from qt/guiutil.cpp
ryanofsky Apr 18, 2017
8549622
Remove direct bitcoin calls from qt/sendcoinsdialog.cpp
ryanofsky Apr 20, 2017
1133dfc
Use WalletBalances struct in Qt
ryanofsky Mar 31, 2018
ce41506
Add developer notes about blocking GUI code
ryanofsky Apr 2, 2018
07600d9
qt: Cleanup in OptionsDialog
xdustinface Aug 28, 2020
3139459
qt|privatesend: Remove unused wallet inlcudes
xdustinface Aug 29, 2020
6c90072
interface/qt: Remove direct src/evo calls
xdustinface Aug 28, 2020
e24b622
interface/qt: Remove direct src/llmq calls
xdustinface Aug 28, 2020
555a184
interface/qt: Remove direct src/masterode calls
xdustinface Aug 27, 2020
1a5a1ca
interface/qt: Remove direct src/privatesend calls
xdustinface Aug 28, 2020
6088650
test: Add boost/signals2/connection.hpp to lint-inlcudes.sh
xdustinface Aug 28, 2020
7c6ceca
Merge #18123: gui: Fix race in WalletModel::pollBalanceChanged
jonasschnelli Feb 13, 2020
79d32b5
test: Fix wallet tests
xdustinface Sep 29, 2020
7ab1051
Partially backport bitcoin#11403
xdustinface Oct 2, 2020
cee8c15
scripted-diff: Merge #12906: Avoid `interface` keyword to fix windows…
xdustinface Oct 1, 2020
5020a68
qt|interfaces: Avoid redundant status update calls
xdustinface Oct 4, 2020
12c840f
Add mempool lock for Create/CommitTransaction in wallet interface
UdjinM6 Oct 3, 2020
4dca83b
wallet: Add CL/IS caches in CMerkleTx
xdustinface Oct 5, 2020
7cf7b53
wallet: Respect chainlocks in CMerkleTx::IsLockedByInstantSend
xdustinface Oct 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,19 @@ GUI
should not interact with the user. That's where View classes come in. The converse also
holds: try to not directly access core data structures from Views.

- Avoid adding slow or blocking code in the GUI thread. In particular do not
add new `interfaces::Node` and `interfaces::Wallet` method calls, even if they
may be fast now, in case they are changed to lock or communicate across
processes in the future.

Prefer to offload work from the GUI thread to worker threads (see
`RPCExecutor` in console code as an example) or take other steps (see
https://doc.qt.io/archives/qq/qq27-responsive-guis.html) to keep the GUI
responsive.

- *Rationale*: Blocking the GUI thread can increase latency, and lead to
hangs and deadlocks.

Subtrees
----------

Expand Down
7 changes: 7 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DIST_SUBDIRS = secp256k1 univalue
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS)
AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS)
AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
AM_LIBTOOLFLAGS = --preserve-dup-deps
EXTRA_LIBRARIES =

if ENABLE_CRASH_HOOKS
Expand Down Expand Up @@ -169,6 +170,9 @@ BITCOIN_CORE_H = \
httpserver.h \
indirectmap.h \
init.h \
interfaces/handler.h \
interfaces/node.h \
interfaces/wallet.h \
key.h \
keepass.h \
keystore.h \
Expand Down Expand Up @@ -378,6 +382,7 @@ endif
libdash_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libdash_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libdash_wallet_a_SOURCES = \
interfaces/wallet.cpp \
keepass.cpp \
privatesend/privatesend-client.cpp \
privatesend/privatesend-util.cpp \
Expand Down Expand Up @@ -548,6 +553,8 @@ libdash_util_a_SOURCES = \
compat/glibcxx_sanity.cpp \
compat/strnlen.cpp \
fs.cpp \
interfaces/handler.cpp \
interfaces/node.cpp \
logging.cpp \
random.cpp \
rpc/protocol.cpp \
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ if TARGET_WINDOWS
endif
qt_dash_qt_LDADD = qt/libdashqt.a $(LIBBITCOIN_SERVER)
if ENABLE_WALLET
qt_dash_qt_LDADD += $(LIBBITCOIN_WALLET)
qt_dash_qt_LDADD += $(LIBBITCOIN_UTIL) $(LIBBITCOIN_WALLET)
endif
if ENABLE_ZMQ
qt_dash_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
Expand All @@ -410,7 +410,7 @@ qt_dash_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(
$(BACKTRACE_LIB) $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(BLS_LIBS)
qt_dash_qt_LDFLAGS = $(LDFLAGS_WRAP_EXCEPTIONS) $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
qt_dash_qt_LIBTOOLFLAGS = --tag CXX
qt_dash_qt_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag CXX

#locale/foo.ts -> locale/foo.qm
QT_QM=$(QT_TS:.ts=.qm)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.qttest.include
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ nodist_qt_test_test_dash_qt_SOURCES = $(TEST_QT_MOC_CPP)

qt_test_test_dash_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER)
if ENABLE_WALLET
qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_WALLET)
qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_UTIL) $(LIBBITCOIN_WALLET)
endif
if ENABLE_ZMQ
qt_test_test_dash_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
Expand Down
17 changes: 17 additions & 0 deletions src/interfaces/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Internal c++ interfaces

The following interfaces are defined here:

* [`Chain`](chain.h) — used by wallet to access blockchain and mempool state. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).

* [`Chain::Client`](chain.h) — used by node to start & stop `Chain` clients. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).

* [`Node`](node.h) — used by GUI to start & stop bitcoin node. Added in [#10244](https://github.com/bitcoin/bitcoin/pull/10244).

* [`Wallet`](wallet.h) — used by GUI to access wallets. Added in [#10244](https://github.com/bitcoin/bitcoin/pull/10244).

* [`Handler`](handler.h) — returned by `handleEvent` methods on interfaces above and used to manage lifetimes of event handlers.

* [`Init`](init.h) — used by multiprocess code to access interfaces above on startup. Added in [#10102](https://github.com/bitcoin/bitcoin/pull/10102).

The interfaces above define boundaries between major components of bitcoin code (node, wallet, and gui), making it possible for them to run in different processes, and be tested, developed, and understood independently. These interfaces are not currently designed to be stable or to be used externally.
33 changes: 33 additions & 0 deletions src/interfaces/handler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <interfaces/handler.h>

#include <util.h>

#include <boost/signals2/connection.hpp>
#include <memory>
#include <utility>

namespace interfaces {
namespace {

class HandlerImpl : public Handler
{
public:
HandlerImpl(boost::signals2::connection connection) : m_connection(std::move(connection)) {}

void disconnect() override { m_connection.disconnect(); }

boost::signals2::scoped_connection m_connection;
};

} // namespace

std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
{
return MakeUnique<HandlerImpl>(std::move(connection));
}

} // namespace interfaces
35 changes: 35 additions & 0 deletions src/interfaces/handler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_INTERFACES_HANDLER_H
#define BITCOIN_INTERFACES_HANDLER_H

#include <memory>

namespace boost {
namespace signals2 {
class connection;
} // namespace signals2
} // namespace boost

namespace interfaces {

//! Generic interface for managing an event handler or callback function
//! registered with another interface. Has a single disconnect method to cancel
//! the registration and prevent any future notifications.
class Handler
{
public:
virtual ~Handler() {}

//! Disconnect the handler.
virtual void disconnect() = 0;
};

//! Return handler wrapping a boost signal connection.
std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection);

} // namespace interfaces

#endif // BITCOIN_INTERFACES_HANDLER_H
Loading