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

Chainstate rm kernel UI interface 0 #12

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions ci/test/06_script_b.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ if [ "${RUN_TIDY}" = "true" ]; then
src/kernel \
src/node/blockmanager_args.cpp \
src/node/chainstate.cpp \
src/node/chainstatemanager_notifications.cpp \
src/node/chainstatemanager_args.cpp \
src/node/mempool_args.cpp \
src/node/minisketchwrapper.cpp \
Expand Down
11 changes: 7 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ BITCOIN_CORE_H = \
compat/compat.h \
compat/cpuid.h \
compat/endian.h \
common/system.h \
compressor.h \
consensus/consensus.h \
consensus/tx_check.h \
Expand Down Expand Up @@ -207,6 +208,7 @@ BITCOIN_CORE_H = \
node/caches.h \
node/chainstate.h \
node/chainstatemanager_args.h \
node/chainstatemanager_notifications.h \
node/coin.h \
node/coins_view_args.h \
node/connection_types.h \
Expand Down Expand Up @@ -277,6 +279,7 @@ BITCOIN_CORE_H = \
txrequest.h \
undo.h \
util/asmap.h \
util/batchpriority.h \
util/bip32.h \
util/bitdeque.h \
util/bytevectorhash.h \
Expand Down Expand Up @@ -308,7 +311,6 @@ BITCOIN_CORE_H = \
util/string.h \
util/syscall_sandbox.h \
util/syserror.h \
util/system.h \
util/thread.h \
util/threadinterrupt.h \
util/threadnames.h \
Expand Down Expand Up @@ -399,6 +401,7 @@ libbitcoin_node_a_SOURCES = \
node/caches.cpp \
node/chainstate.cpp \
node/chainstatemanager_args.cpp \
node/chainstatemanager_notifications.cpp \
node/coin.cpp \
node/coins_view_args.cpp \
node/connection_types.cpp \
Expand Down Expand Up @@ -655,6 +658,7 @@ libbitcoin_common_a_SOURCES = \
common/init.cpp \
common/interfaces.cpp \
common/run_command.cpp \
common/system.cpp \
compressor.cpp \
core_read.cpp \
core_write.cpp \
Expand Down Expand Up @@ -706,6 +710,7 @@ libbitcoin_util_a_SOURCES = \
support/cleanse.cpp \
sync.cpp \
util/asmap.cpp \
util/batchpriority.cpp \
util/bip32.cpp \
util/bytevectorhash.cpp \
util/chaintype.cpp \
Expand All @@ -719,7 +724,6 @@ libbitcoin_util_a_SOURCES = \
util/hasher.cpp \
util/sock.cpp \
util/syserror.cpp \
util/system.cpp \
util/message.cpp \
util/moneystr.cpp \
util/rbf.cpp \
Expand Down Expand Up @@ -930,7 +934,6 @@ libbitcoinkernel_la_SOURCES = \
logging.cpp \
node/blockstorage.cpp \
node/chainstate.cpp \
node/interface_ui.cpp \
node/utxo_snapshot.cpp \
policy/feerate.cpp \
policy/fees.cpp \
Expand Down Expand Up @@ -958,6 +961,7 @@ libbitcoinkernel_la_SOURCES = \
txdb.cpp \
txmempool.cpp \
uint256.cpp \
util/batchpriority.cpp \
util/chaintype.cpp \
util/check.cpp \
util/exception.cpp \
Expand All @@ -973,7 +977,6 @@ libbitcoinkernel_la_SOURCES = \
util/string.cpp \
util/syscall_sandbox.cpp \
util/syserror.cpp \
util/system.cpp \
util/thread.cpp \
util/threadnames.cpp \
util/time.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/banman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <banman.h>

#include <common/system.h>
#include <logging.h>
#include <netaddress.h>
#include <node/interface_ui.h>
#include <sync.h>
#include <util/system.h>
#include <util/time.h>
#include <util/translation.h>

Expand Down
2 changes: 1 addition & 1 deletion src/bench/checkqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include <bench/bench.h>
#include <checkqueue.h>
#include <common/system.h>
#include <key.h>
#include <prevector.h>
#include <pubkey.h>
#include <random.h>
#include <util/system.h>

#include <vector>

Expand Down
7 changes: 7 additions & 0 deletions src/bitcoin-chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ int main(int argc, char* argv[])
.chainparams = *chainparams,
.datadir = gArgs.GetDataDirNet(),
.adjusted_time_callback = NodeClock::now,
.notification_callbacks = ChainstateManager::NotificationCallbacks{
.notify_block_tip = [](SynchronizationState state, CBlockIndex* index) { std::cout << "Block tip changed" << std::endl; },
.notify_header_tip = [](SynchronizationState, int64_t height, int64_t timestamp, bool presync) { std::cout << "Header tip changed: " << height << ", " << timestamp << ", " << presync << std::endl; },
.show_progress = [](const std::string& title, int nProgress, bool resume_possible) { std::cout << "Progress: " << title << ", " << nProgress << ", " << resume_possible << std::endl; },
.do_warning = [](const bilingual_str& warning) { std::cout << "Warning: " << warning.original << std::endl; },
.init_error = [](const bilingual_str& user_message) { std::cout << "Init error: " << user_message.original << std::endl; },
},
};
const node::BlockManager::Options blockman_opts{
.chainparams = chainman_opts.chainparams,
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/system.h>
#include <common/url.h>
#include <compat/compat.h>
#include <compat/stdin.h>
Expand All @@ -23,7 +24,6 @@
#include <util/chaintype.h>
#include <util/exception.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <util/time.h>
#include <util/translation.h>

Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <clientversion.h>
#include <coins.h>
#include <common/args.h>
#include <common/system.h>
#include <compat/compat.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
Expand All @@ -27,7 +28,6 @@
#include <util/rbf.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/system.h>
#include <util/translation.h>

#include <cstdio>
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/system.h>
#include <compat/compat.h>
#include <core_io.h>
#include <streams.h>
#include <util/exception.h>
#include <util/system.h>
#include <util/translation.h>
#include <version.h>

Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/system.h>
#include <common/url.h>
#include <compat/compat.h>
#include <interfaces/init.h>
Expand All @@ -18,7 +19,6 @@
#include <pubkey.h>
#include <tinyformat.h>
#include <util/exception.h>
#include <util/system.h>
#include <util/translation.h>
#include <wallet/wallettool.h>

Expand Down
2 changes: 1 addition & 1 deletion src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <clientversion.h>
#include <common/args.h>
#include <common/init.h>
#include <common/system.h>
#include <common/url.h>
#include <compat/compat.h>
#include <init.h>
Expand All @@ -25,7 +26,6 @@
#include <util/strencodings.h>
#include <util/syscall_sandbox.h>
#include <util/syserror.h>
#include <util/system.h>
#include <util/threadnames.h>
#include <util/tokenpipe.h>
#include <util/translation.h>
Expand Down
4 changes: 2 additions & 2 deletions src/blockencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <blockencodings.h>
#include <chainparams.h>
#include <common/system.h>
#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <chainparams.h>
#include <crypto/sha256.h>
#include <crypto/siphash.h>
#include <random.h>
#include <streams.h>
#include <txmempool.h>
#include <validation.h>
#include <util/system.h>

#include <unordered_map>

Expand Down
20 changes: 1 addition & 19 deletions src/util/system.cpp → src/common/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <util/system.h>
#include <common/system.h>

#include <logging.h>
#include <util/string.h>
#include <util/syserror.h>
#include <util/time.h>

#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
#include <pthread.h>
#include <pthread_np.h>
#endif

#ifndef WIN32
#include <sched.h>
#include <sys/stat.h>
#else
#include <codecvt>
Expand Down Expand Up @@ -112,14 +105,3 @@ int64_t GetStartupTime()
{
return nStartupTime;
}

void ScheduleBatchPriority()
{
#ifdef SCHED_BATCH
const static sched_param param{};
const int rc = pthread_setschedparam(pthread_self(), SCHED_BATCH, &param);
if (rc != 0) {
LogPrintf("Failed to pthread_setschedparam: %s\n", SysErrorString(rc));
}
#endif
}
13 changes: 3 additions & 10 deletions src/util/system.h → src/common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_UTIL_SYSTEM_H
#define BITCOIN_UTIL_SYSTEM_H
#ifndef BITCOIN_COMMON_SYSTEM_H
#define BITCOIN_COMMON_SYSTEM_H

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
Expand Down Expand Up @@ -36,13 +36,6 @@ void runCommand(const std::string& strCommand);
*/
int GetNumCores();

/**
* On platforms that support it, tell the kernel the calling thread is
* CPU-intensive and non-interactive. See SCHED_BATCH in sched(7) for details.
*
*/
void ScheduleBatchPriority();

namespace util {

//! Simplification of std insertion
Expand All @@ -69,4 +62,4 @@ T* AnyPtr(const std::any& any) noexcept

} // namespace util

#endif // BITCOIN_UTIL_SYSTEM_H
#endif // BITCOIN_COMMON_SYSTEM_H
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <core_io.h>

#include <common/system.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <consensus/validation.h>
Expand All @@ -17,7 +18,6 @@
#include <univalue.h>
#include <util/check.h>
#include <util/strencodings.h>
#include <util/system.h>

#include <map>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion src/external_signer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef BITCOIN_EXTERNAL_SIGNER_H
#define BITCOIN_EXTERNAL_SIGNER_H

#include <common/system.h>
#include <univalue.h>
#include <util/system.h>

#include <string>
#include <vector>
Expand Down
10 changes: 8 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <chainparams.h>
#include <chainparamsbase.h>
#include <common/args.h>
#include <common/system.h>
#include <consensus/amount.h>
#include <deploymentstatus.h>
#include <hash.h>
Expand All @@ -43,6 +44,7 @@
#include <node/caches.h>
#include <node/chainstate.h>
#include <node/chainstatemanager_args.h>
#include <node/chainstatemanager_notifications.h>
#include <node/context.h>
#include <node/interface_ui.h>
#include <node/mempool_args.h>
Expand Down Expand Up @@ -79,13 +81,13 @@
#include <util/string.h>
#include <util/syscall_sandbox.h>
#include <util/syserror.h>
#include <util/system.h>
#include <util/thread.h>
#include <util/threadnames.h>
#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
#include <walletinitinterface.h>
#include <warnings.h>

#include <algorithm>
#include <condition_variable>
Expand Down Expand Up @@ -122,6 +124,7 @@ using node::CacheSizes;
using node::CalculateCacheSizes;
using node::DEFAULT_PERSIST_MEMPOOL;
using node::DEFAULT_PRINTPRIORITY;
using node::DefaultChainstateManagerNotifications;
using node::fReindex;
using node::LoadChainstate;
using node::MempoolPath;
Expand Down Expand Up @@ -1445,13 +1448,16 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
.chainparams = chainparams,
.datadir = args.GetDataDirNet(),
.adjusted_time_callback = GetAdjustedTime,
.notification_callbacks = DefaultChainstateManagerNotifications(),
};
Assert(!ApplyArgsManOptions(args, chainman_opts)); // no error can happen, already checked in AppInitParameterInteraction

BlockManager::Options blockman_opts{
.chainparams = chainman_opts.chainparams,
.blocks_dir = args.GetBlocksDirPath(),
};
.init_error_callback = [](const bilingual_str& user_message) {
InitError(user_message);
}};
Assert(!ApplyArgsManOptions(args, blockman_opts)); // no error can happen, already checked in AppInitParameterInteraction

// cache size calculations
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <common/system.h>
#include <interfaces/init.h>
#include <interfaces/ipc.h>
#include <ipc/capnp/protocol.h>
Expand All @@ -10,7 +11,6 @@
#include <logging.h>
#include <tinyformat.h>
#include <util/fs.h>
#include <util/system.h>

#include <cstdio>
#include <cstdlib>
Expand Down
Loading