mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
6db04be102Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directly (Ryan Ofsky)213542b625refactor: Add InitContext function to initialize NodeContext with global pointers (Ryan Ofsky)feeb7b816arefactor: Remove calls to StartShutdown from KernelNotifications (Ryan Ofsky)6824eecaf1refactor: Remove call to StartShutdown from stop RPC (Ryan Ofsky)1d92d89edbutil: Get rid of uncaught exceptions thrown by SignalInterrupt class (Ryan Ofsky)ba93966368refactor: Remove call to ShutdownRequested from IndexWaitSynced (Ryan Ofsky)42e5829d97refactor: Remove call to ShutdownRequested from HTTPRequest (Ryan Ofsky)73133c36aarefactor: Add NodeContext::shutdown member (Ryan Ofsky)f4a8bd6e2frefactor: Remove call to StartShutdown from qt (Ryan Ofsky)f0c73c1336refactor: Remove call to ShutdownRequested from rpc/mining (Ryan Ofsky)263b23f008refactor: Remove call to ShutdownRequested from chainstate init (Ryan Ofsky) Pull request description: This change drops `shutdown.h` and `shutdown.cpp` files, replacing them with a `NodeContext::shutdown` member which is used to trigger shutdowns directly. This gets rid of an unnecessary layer of indirection, and allows getting rid of the `kernel::g_context` global. Additionally, this PR tries to improve error handling of `SignalInterrupt` code by marking relevant methods `[[nodiscard]]` to avoid the possibility of uncaught exceptions mentioned https://github.com/bitcoin/bitcoin/pull/27861#discussion_r1255496707. Behavior is changing In a few cases which are noted in individual commit messages. Particularly: GUI code more consistently interrupts RPCs when it is shutting down, shutdown state no longer persists between unit tests, the stop RPC now returns an RPC error if requesting shutdown fails instead of aborting, and other failed shutdown calls now log errors instead of aborting. This PR is a net reduction in lines of code, but in some cases the explicit error handling and lack of global shutdown functions do make it more verbose. The verbosity can be seen as good thing if it discourages more code from directly triggering shutdowns, and instead encourages code to return errors or send notifications that could be translated into shutdowns. Probably a number of existing shutdown calls could just be replaced by better error handling. ACKs for top commit: achow101: ACK6db04be102TheCharlatan: Re-ACK6db04be102maflcko: ACK6db04be102👗 stickies-v: re-ACK6db04be102Tree-SHA512: 7a34cb69085f37e813c43bdaded1a0cbf6c53bd95fdde96f0cb45346127fc934604c43bccd3328231ca2f1faf712a7418d047ceabd22ef2dca3c32ebb659e634
Test library
This contains files for the test library, which is used by the test binaries (unit tests, benchmarks, fuzzers, gui tests).
Generally, the files in this folder should be well-separated modules. New code should be added to existing modules or (when in doubt) a new module should be created.
The utilities in here are compiled into a library, which does not hold any state. However, the main file setup_common
defines the common test setup for all test binaries. The test binaries will handle the global state when they
instantiate the BasicTestingSetup (or one of its derived classes).