Skip to content

Commit 9564f98

Browse files
committed
Merge bitcoin/bitcoin#27636: kernel: Remove util/system from kernel library, interface_ui from validation.
7d3b350 refactor: Move system from util to common library (TheCharlatan) 7eee356 refactor: Split util::AnyPtr into its own file (TheCharlatan) 44de325 refactor: Split util::insert into its own file (TheCharlatan) 9ec5da3 refactor: Move ScheduleBatchPriority to its own file (TheCharlatan) f871c69 kernel: Add warning method to notifications (TheCharlatan) 4452707 kernel: Add progress method to notifications (TheCharlatan) 84d7145 kernel: Add headerTip method to notifications (TheCharlatan) 447761c kernel: Add notification interface (TheCharlatan) Pull request description: This pull request is part of the `libbitcoinkernel` project bitcoin/bitcoin#27587 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". --- It removes the kernel library's dependency on `util/system` and `interface_ui`. `util/system` contains networking and shell-related code that should not be part of the kernel library. The following pull requests prepared `util/system` for this final step: bitcoin/bitcoin#27419 bitcoin/bitcoin#27254 bitcoin/bitcoin#27238. `interface_ui` defines functions for a more general node interface and has a dependency on `boost/signals2`. After applying the patches from this pull request, the kernel's reliance on boost is down to `boost::multiindex`. The approach implemented here introduces some indirection, which makes the code a bit harder to read. Any suggestions for improving or reworking this pull request to make it more concise, or even reworking it into a more proper interface, are appreciated. ACKs for top commit: MarcoFalke: re-ACK 7d3b350 (no change) 🎋 stickies-v: Code Review ACK 7d3b350 hebasto: re-ACK 7d3b350, only last two commits dropped since my [recent](bitcoin/bitcoin#27636 (review)) review. Tree-SHA512: c8cfc698dc9d78e20191c444708f2d957501229abe95e5806106d1126fb9c5fbcee686fb55645658c0107ce71f10646f37a2fdf7fde16bbf22cbf1ac885dd08d
2 parents f467b28 + 7d3b350 commit 9564f98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+421
-212
lines changed

src/Makefile.am

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ BITCOIN_CORE_H = \
143143
compat/compat.h \
144144
compat/cpuid.h \
145145
compat/endian.h \
146+
common/system.h \
146147
compressor.h \
147148
consensus/consensus.h \
148149
consensus/tx_check.h \
@@ -186,6 +187,7 @@ BITCOIN_CORE_H = \
186187
kernel/mempool_limits.h \
187188
kernel/mempool_options.h \
188189
kernel/mempool_persist.h \
190+
kernel/notifications_interface.h \
189191
kernel/validation_cache_sizes.h \
190192
key.h \
191193
key_io.h \
@@ -214,6 +216,7 @@ BITCOIN_CORE_H = \
214216
node/database_args.h \
215217
node/eviction.h \
216218
node/interface_ui.h \
219+
node/kernel_notifications.h \
217220
node/mempool_args.h \
218221
node/mempool_persist_args.h \
219222
node/miner.h \
@@ -277,7 +280,9 @@ BITCOIN_CORE_H = \
277280
txorphanage.h \
278281
txrequest.h \
279282
undo.h \
283+
util/any.h \
280284
util/asmap.h \
285+
util/batchpriority.h \
281286
util/bip32.h \
282287
util/bitdeque.h \
283288
util/bytevectorhash.h \
@@ -294,6 +299,7 @@ BITCOIN_CORE_H = \
294299
util/golombrice.h \
295300
util/hash_type.h \
296301
util/hasher.h \
302+
util/insert.h \
297303
util/macros.h \
298304
util/message.h \
299305
util/moneystr.h \
@@ -309,7 +315,6 @@ BITCOIN_CORE_H = \
309315
util/string.h \
310316
util/syscall_sandbox.h \
311317
util/syserror.h \
312-
util/system.h \
313318
util/thread.h \
314319
util/threadinterrupt.h \
315320
util/threadnames.h \
@@ -408,6 +413,7 @@ libbitcoin_node_a_SOURCES = \
408413
node/eviction.cpp \
409414
node/interface_ui.cpp \
410415
node/interfaces.cpp \
416+
node/kernel_notifications.cpp \
411417
node/mempool_args.cpp \
412418
node/mempool_persist_args.cpp \
413419
node/miner.cpp \
@@ -657,6 +663,7 @@ libbitcoin_common_a_SOURCES = \
657663
common/init.cpp \
658664
common/interfaces.cpp \
659665
common/run_command.cpp \
666+
common/system.cpp \
660667
compressor.cpp \
661668
core_read.cpp \
662669
core_write.cpp \
@@ -708,6 +715,7 @@ libbitcoin_util_a_SOURCES = \
708715
support/cleanse.cpp \
709716
sync.cpp \
710717
util/asmap.cpp \
718+
util/batchpriority.cpp \
711719
util/bip32.cpp \
712720
util/bytevectorhash.cpp \
713721
util/chaintype.cpp \
@@ -721,7 +729,6 @@ libbitcoin_util_a_SOURCES = \
721729
util/hasher.cpp \
722730
util/sock.cpp \
723731
util/syserror.cpp \
724-
util/system.cpp \
725732
util/message.cpp \
726733
util/moneystr.cpp \
727734
util/rbf.cpp \
@@ -960,6 +967,7 @@ libbitcoinkernel_la_SOURCES = \
960967
txdb.cpp \
961968
txmempool.cpp \
962969
uint256.cpp \
970+
util/batchpriority.cpp \
963971
util/chaintype.cpp \
964972
util/check.cpp \
965973
util/exception.cpp \
@@ -975,7 +983,6 @@ libbitcoinkernel_la_SOURCES = \
975983
util/string.cpp \
976984
util/syscall_sandbox.cpp \
977985
util/syserror.cpp \
978-
util/system.cpp \
979986
util/thread.cpp \
980987
util/threadnames.cpp \
981988
util/time.cpp \

src/banman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
#include <banman.h>
77

8+
#include <common/system.h>
89
#include <logging.h>
910
#include <netaddress.h>
1011
#include <node/interface_ui.h>
1112
#include <sync.h>
12-
#include <util/system.h>
1313
#include <util/time.h>
1414
#include <util/translation.h>
1515

src/bench/checkqueue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
#include <bench/bench.h>
66
#include <checkqueue.h>
7+
#include <common/system.h>
78
#include <key.h>
89
#include <prevector.h>
910
#include <pubkey.h>
1011
#include <random.h>
11-
#include <util/system.h>
1212

1313
#include <vector>
1414

src/bitcoin-chainstate.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// It is part of the libbitcoinkernel project.
1313

1414
#include <kernel/chainparams.h>
15+
#include <kernel/chainstatemanager_opts.h>
1516
#include <kernel/checks.h>
1617
#include <kernel/context.h>
1718
#include <kernel/validation_cache_sizes.h>
@@ -31,9 +32,12 @@
3132
#include <validationinterface.h>
3233

3334
#include <cassert>
35+
#include <cstdint>
3436
#include <filesystem>
3537
#include <functional>
3638
#include <iosfwd>
39+
#include <memory>
40+
#include <string>
3741

3842
int main(int argc, char* argv[])
3943
{
@@ -80,12 +84,34 @@ int main(int argc, char* argv[])
8084

8185
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
8286

87+
class KernelNotifications : public kernel::Notifications
88+
{
89+
public:
90+
void blockTip(SynchronizationState, CBlockIndex&) override
91+
{
92+
std::cout << "Block tip changed" << std::endl;
93+
}
94+
void headerTip(SynchronizationState, int64_t height, int64_t timestamp, bool presync) override
95+
{
96+
std::cout << "Header tip changed: " << height << ", " << timestamp << ", " << presync << std::endl;
97+
}
98+
void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override
99+
{
100+
std::cout << "Progress: " << title.original << ", " << progress_percent << ", " << resume_possible << std::endl;
101+
}
102+
void warning(const bilingual_str& warning) override
103+
{
104+
std::cout << "Warning: " << warning.original << std::endl;
105+
}
106+
};
107+
auto notifications = std::make_unique<KernelNotifications>();
83108

84109
// SETUP: Chainstate
85110
const ChainstateManager::Options chainman_opts{
86111
.chainparams = *chainparams,
87112
.datadir = gArgs.GetDataDirNet(),
88113
.adjusted_time_callback = NodeClock::now,
114+
.notifications = *notifications,
89115
};
90116
const node::BlockManager::Options blockman_opts{
91117
.chainparams = chainman_opts.chainparams,

src/bitcoin-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <chainparamsbase.h>
1111
#include <clientversion.h>
1212
#include <common/args.h>
13+
#include <common/system.h>
1314
#include <common/url.h>
1415
#include <compat/compat.h>
1516
#include <compat/stdin.h>
@@ -23,7 +24,6 @@
2324
#include <util/chaintype.h>
2425
#include <util/exception.h>
2526
#include <util/strencodings.h>
26-
#include <util/system.h>
2727
#include <util/time.h>
2828
#include <util/translation.h>
2929

src/bitcoin-tx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <clientversion.h>
1111
#include <coins.h>
1212
#include <common/args.h>
13+
#include <common/system.h>
1314
#include <compat/compat.h>
1415
#include <consensus/amount.h>
1516
#include <consensus/consensus.h>
@@ -27,7 +28,6 @@
2728
#include <util/rbf.h>
2829
#include <util/strencodings.h>
2930
#include <util/string.h>
30-
#include <util/system.h>
3131
#include <util/translation.h>
3232

3333
#include <cstdio>

src/bitcoin-util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
#include <chainparamsbase.h>
1313
#include <clientversion.h>
1414
#include <common/args.h>
15+
#include <common/system.h>
1516
#include <compat/compat.h>
1617
#include <core_io.h>
1718
#include <streams.h>
1819
#include <util/exception.h>
19-
#include <util/system.h>
2020
#include <util/translation.h>
2121
#include <version.h>
2222

src/bitcoin-wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <chainparamsbase.h>
1111
#include <clientversion.h>
1212
#include <common/args.h>
13+
#include <common/system.h>
1314
#include <common/url.h>
1415
#include <compat/compat.h>
1516
#include <interfaces/init.h>
@@ -18,7 +19,6 @@
1819
#include <pubkey.h>
1920
#include <tinyformat.h>
2021
#include <util/exception.h>
21-
#include <util/system.h>
2222
#include <util/translation.h>
2323
#include <wallet/wallettool.h>
2424

src/bitcoind.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <clientversion.h>
1212
#include <common/args.h>
1313
#include <common/init.h>
14+
#include <common/system.h>
1415
#include <common/url.h>
1516
#include <compat/compat.h>
1617
#include <init.h>
@@ -25,7 +26,6 @@
2526
#include <util/strencodings.h>
2627
#include <util/syscall_sandbox.h>
2728
#include <util/syserror.h>
28-
#include <util/system.h>
2929
#include <util/threadnames.h>
3030
#include <util/tokenpipe.h>
3131
#include <util/translation.h>

src/blockencodings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <blockencodings.h>
6+
#include <chainparams.h>
7+
#include <common/system.h>
68
#include <consensus/consensus.h>
79
#include <consensus/validation.h>
8-
#include <chainparams.h>
910
#include <crypto/sha256.h>
1011
#include <crypto/siphash.h>
1112
#include <random.h>
1213
#include <streams.h>
1314
#include <txmempool.h>
1415
#include <validation.h>
15-
#include <util/system.h>
1616

1717
#include <unordered_map>
1818

0 commit comments

Comments
 (0)