├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── README.md ├── autogen.sh ├── benchmark.txt ├── build.cmd ├── builds ├── cmake │ ├── CMakeLists.txt │ ├── CMakePresets.json │ └── modules │ │ ├── FindBash-Completion.cmake │ │ ├── FindBitcoin-Consensus.cmake │ │ ├── FindBitcoin-Database.cmake │ │ └── FindBitcoin-Network.cmake ├── msvc │ ├── .gitignore │ ├── build │ │ ├── build_all.bat │ │ ├── build_base.bat │ │ └── nuget_all.bat │ ├── debug.natvis │ ├── nuget.config │ ├── properties │ │ ├── Arm.props │ │ ├── Arm64.props │ │ ├── Common.props │ │ ├── DLL.props │ │ ├── Debug.props │ │ ├── DebugDEXE.props │ │ ├── DebugDLL.props │ │ ├── DebugLEXE.props │ │ ├── DebugLIB.props │ │ ├── DebugLTCG.props │ │ ├── DebugSEXE.props │ │ ├── EXE.props │ │ ├── LIB.props │ │ ├── LTCG.props │ │ ├── Link.props │ │ ├── Messages.props │ │ ├── Output.props │ │ ├── Release.props │ │ ├── ReleaseDEXE.props │ │ ├── ReleaseDLL.props │ │ ├── ReleaseLEXE.props │ │ ├── ReleaseLIB.props │ │ ├── ReleaseLTCG.props │ │ ├── ReleaseSEXE.props │ │ ├── Win32.props │ │ └── x64.props │ ├── resource.h │ ├── resource.rc │ └── vs2022 │ │ ├── bn │ │ ├── bn.props │ │ ├── bn.vcxproj │ │ ├── bn.vcxproj.filters │ │ └── packages.config │ │ ├── libbitcoin-database.import.props │ │ ├── libbitcoin-database.import.xml │ │ ├── libbitcoin-network.import.props │ │ ├── libbitcoin-network.import.xml │ │ ├── libbitcoin-node-test │ │ ├── libbitcoin-node-test.props │ │ ├── libbitcoin-node-test.vcxproj │ │ ├── libbitcoin-node-test.vcxproj.filters │ │ └── packages.config │ │ ├── libbitcoin-node.import.props │ │ ├── libbitcoin-node.import.xml │ │ ├── libbitcoin-node.sln │ │ ├── libbitcoin-node │ │ ├── libbitcoin-node.props │ │ ├── libbitcoin-node.vcxproj │ │ ├── libbitcoin-node.vcxproj.filters │ │ └── packages.config │ │ ├── libbitcoin-system.import.props │ │ └── libbitcoin-system.import.xml └── vscode │ └── node.code-workspace ├── configure.ac ├── console ├── executor.cpp ├── executor.hpp ├── executor_commands.cpp ├── executor_dumps.cpp ├── executor_events.cpp ├── executor_logging.cpp ├── executor_options.cpp ├── executor_runner.cpp ├── executor_scans.cpp ├── executor_store.cpp ├── executor_test_reader.cpp ├── executor_test_writer.cpp ├── libbitcoin.ico ├── localize.hpp ├── main.cpp ├── stack_trace.cpp └── stack_trace.hpp ├── data ├── bn └── bn.cfg ├── include └── bitcoin │ ├── node.hpp │ └── node │ ├── block_arena.hpp │ ├── block_memory.hpp │ ├── chase.hpp │ ├── chasers │ ├── chaser.hpp │ ├── chaser_block.hpp │ ├── chaser_check.hpp │ ├── chaser_confirm.hpp │ ├── chaser_header.hpp │ ├── chaser_organize.hpp │ ├── chaser_snapshot.hpp │ ├── chaser_storage.hpp │ ├── chaser_template.hpp │ ├── chaser_transaction.hpp │ ├── chaser_validate.hpp │ └── chasers.hpp │ ├── configuration.hpp │ ├── define.hpp │ ├── error.hpp │ ├── events.hpp │ ├── full_node.hpp │ ├── impl │ └── chasers │ │ └── chaser_organize.ipp │ ├── parser.hpp │ ├── protocols │ ├── protocol.hpp │ ├── protocol_block_in.hpp │ ├── protocol_block_in_31800.hpp │ ├── protocol_block_out.hpp │ ├── protocol_header_in_31800.hpp │ ├── protocol_header_in_70012.hpp │ ├── protocol_header_out_31800.hpp │ ├── protocol_header_out_70012.hpp │ ├── protocol_observer.hpp │ ├── protocol_performer.hpp │ ├── protocol_transaction_in.hpp │ ├── protocol_transaction_out.hpp │ └── protocols.hpp │ ├── sessions │ ├── attach.hpp │ ├── session.hpp │ ├── session_inbound.hpp │ ├── session_manual.hpp │ ├── session_outbound.hpp │ └── sessions.hpp │ ├── settings.hpp │ └── version.hpp ├── install-cmake.sh ├── install-cmakepresets.sh ├── install.sh ├── libbitcoin-node-test_runner.sh ├── libbitcoin-node.pc.in ├── m4 ├── .gitignore ├── ax_boost_base.m4 ├── ax_boost_unit_test_framework.m4 ├── ax_check_compile_flag.m4 ├── ax_check_link_flag.m4 ├── ax_check_preproc_flag.m4 └── ax_cxx_compile_stdcxx.m4 ├── src ├── block_arena.cpp ├── block_memory.cpp ├── chasers │ ├── chaser.cpp │ ├── chaser_block.cpp │ ├── chaser_check.cpp │ ├── chaser_confirm.cpp │ ├── chaser_header.cpp │ ├── chaser_snapshot.cpp │ ├── chaser_storage.cpp │ ├── chaser_template.cpp │ ├── chaser_transaction.cpp │ └── chaser_validate.cpp ├── configuration.cpp ├── error.cpp ├── full_node.cpp ├── parser.cpp ├── protocols │ ├── protocol.cpp │ ├── protocol_block_in.cpp │ ├── protocol_block_in_31800.cpp │ ├── protocol_block_out.cpp │ ├── protocol_header_in_31800.cpp │ ├── protocol_header_in_70012.cpp │ ├── protocol_header_out_31800.cpp │ ├── protocol_header_out_70012.cpp │ ├── protocol_observer.cpp │ ├── protocol_performer.cpp │ ├── protocol_transaction_in.cpp │ └── protocol_transaction_out.cpp ├── sessions │ ├── session.cpp │ ├── session_inbound.cpp │ ├── session_manual.cpp │ └── session_outbound.cpp └── settings.cpp └── test ├── block_arena.cpp ├── block_memory.cpp ├── chasers ├── chaser.cpp ├── chaser_block.cpp ├── chaser_check.cpp ├── chaser_confirm.cpp ├── chaser_header.cpp ├── chaser_template.cpp ├── chaser_transaction.cpp └── chaser_validate.cpp ├── configuration.cpp ├── error.cpp ├── full_node.cpp ├── main.cpp ├── node.cpp ├── protocols └── protocol.cpp ├── sessions └── session.cpp ├── settings.cpp ├── test.cpp └── test.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | *.la 4 | *.lo 5 | *.o 6 | *.pyc 7 | Makefile 8 | Makefile.in 9 | libbitcoin-node.pc 10 | 11 | bin 12 | obj 13 | build 14 | .*.swp 15 | *~ 16 | /*.kdev4 17 | /.cproject 18 | /.project 19 | /.settings 20 | /nbproject 21 | 22 | /aclocal.m4 23 | /autom4te.cache 24 | /build-aux 25 | /config.* 26 | /configure 27 | /libtool 28 | .dirstamp 29 | 30 | node_test/ 31 | /builds/msvc/vs2022/bn/hosts.cache 32 | *.lock 33 | *.vsidx 34 | *.txt 35 | *.data 36 | *.head 37 | /.vs 38 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Launch", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/obj/nix-gnu-debug-static/libbitcoin-node-test", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}/obj/nix-gnu-debug-static", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "gdb", 18 | "setupCommands": [ 19 | { 20 | "description": "Enable pretty-printing for gdb", 21 | "text": "-enable-pretty-printing", 22 | "ignoreFailures": true 23 | }, 24 | { 25 | "description": "Set Disassembly Flavor to Intel", 26 | "text": "-gdb-set disassembly-flavor intel", 27 | "ignoreFailures": true 28 | } 29 | ] 30 | } 31 | 32 | ] 33 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmake.sourceDirectory": "${workspaceFolder}/builds/cmake", 3 | "cmake.useCMakePresets": "always" 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "cmake", 6 | "label": "CMake: build", 7 | "command": "build", 8 | "targets": [ 9 | "all" 10 | ], 11 | "preset": "${command:cmake.activeBuildPresetName}", 12 | "group": "build", 13 | "problemMatcher": [], 14 | "detail": "CMake template build task" 15 | }, 16 | { 17 | "type": "cmake", 18 | "label": "CMake: clean", 19 | "command": "clean", 20 | "preset": "${command:cmake.activeBuildPresetName}", 21 | "problemMatcher": [], 22 | "detail": "CMake template clean task" 23 | }, 24 | { 25 | "type": "cmake", 26 | "label": "CMake: install", 27 | "command": "install", 28 | "preset": "${command:cmake.activeBuildPresetName}", 29 | "problemMatcher": [], 30 | "detail": "CMake template install task" 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | commits libbitcoin developers 2 | -------------------------------------------- 3 | 977 Eric Voskuil (evoskuil) 4 | 60 Phillip Mienk (pmienk) 5 | 12 Amir Taaki (genjix) 6 | 1 Lucas Betschart (lclc) 7 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | Use command 'git log --oneline --decorate' for latest change log. 2 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | See https://libbitcoin.org -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | See README.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This branch is not usable in its current state. Please see [version3](https://github.com/libbitcoin/libbitcoin-node/tree/version3) for the latest functional branch. 2 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ############################################################################### 3 | # Copyright (c) 2014-2025 libbitcoin-node developers (see COPYING). 4 | # 5 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 6 | # 7 | ############################################################################### 8 | 9 | autoreconf -i 10 | -------------------------------------------------------------------------------- /builds/cmake/modules/FindBash-Completion.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2014-2025 libbitcoin-server developers (see COPYING). 3 | # 4 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | # 6 | ############################################################################### 7 | # FindBash-Completion 8 | # 9 | # Use this module by invoking find_package with the form:: 10 | # 11 | # find_package( Bash-Completion 12 | # [version] # Minimum version 13 | # [REQUIRED] # Fail with error if bash-completion is not found 14 | # ) 15 | # 16 | # Defines the following for use: 17 | # 18 | # bash_completion_FOUND - true if headers and requested libraries were found 19 | # bash_completion_INCLUDE_DIRS - include directories for bash-completion libraries 20 | # bash_completion_LIBRARY_DIRS - link directories for bash-completion libraries 21 | # bash_completion_LIBRARIES - bash-completion libraries to be linked 22 | # bash_completion_PKG - bash-completion pkg-config package specification. 23 | # 24 | 25 | if (MSVC) 26 | if ( Bash-Completion_FIND_REQUIRED ) 27 | set( _bash_completion_MSG_STATUS "SEND_ERROR" ) 28 | else () 29 | set( _bash_completion_MSG_STATUS "STATUS" ) 30 | endif() 31 | 32 | set( bash_completion_FOUND false ) 33 | message( ${_bash_completion_MSG_STATUS} "MSVC environment detection for 'bash-completion' not currently supported." ) 34 | else () 35 | # required 36 | if ( Bash-Completion_FIND_REQUIRED ) 37 | set( _bash_completion_REQUIRED "REQUIRED" ) 38 | endif() 39 | 40 | # quiet 41 | if ( Bash-Completion_FIND_QUIETLY ) 42 | set( _bash_completion_QUIET "QUIET" ) 43 | endif() 44 | 45 | # modulespec 46 | if ( Bash-Completion_FIND_VERSION_COUNT EQUAL 0 ) 47 | set( _bash_completion_MODULE_SPEC "bash-completion" ) 48 | else () 49 | if ( Bash-Completion_FIND_VERSION_EXACT ) 50 | set( _bash_completion_MODULE_SPEC_OP "=" ) 51 | else () 52 | set( _bash_completion_MODULE_SPEC_OP ">=" ) 53 | endif() 54 | 55 | set( _bash_completion_MODULE_SPEC "bash-completion ${_bash_completion_MODULE_SPEC_OP} ${Bash-Completion_FIND_VERSION}" ) 56 | endif() 57 | 58 | pkg_check_modules( bash_completion ${_bash_completion_REQUIRED} ${_bash_completion_QUIET} "${_bash_completion_MODULE_SPEC}" ) 59 | set( bash_completion_PKG "${_bash_completion_MODULE_SPEC}" ) 60 | endif() 61 | -------------------------------------------------------------------------------- /builds/cmake/modules/FindBitcoin-Consensus.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2014-2025 libbitcoin-blockchain developers (see COPYING). 3 | # 4 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | # 6 | ############################################################################### 7 | # FindBitcoin-Consensus 8 | # 9 | # Use this module by invoking find_package with the form:: 10 | # 11 | # find_package( Bitcoin-Consensus 12 | # [version] # Minimum version 13 | # [REQUIRED] # Fail with error if bitcoin-consensus is not found 14 | # ) 15 | # 16 | # Defines the following for use: 17 | # 18 | # bitcoin_consensus_FOUND - true if headers and requested libraries were found 19 | # bitcoin_consensus_INCLUDE_DIRS - include directories for bitcoin-consensus libraries 20 | # bitcoin_consensus_LIBRARY_DIRS - link directories for bitcoin-consensus libraries 21 | # bitcoin_consensus_LIBRARIES - bitcoin-consensus libraries to be linked 22 | # bitcoin_consensus_PKG - bitcoin-consensus pkg-config package specification. 23 | # 24 | 25 | if (MSVC) 26 | if ( Bitcoin-Consensus_FIND_REQUIRED ) 27 | set( _bitcoin_consensus_MSG_STATUS "SEND_ERROR" ) 28 | else () 29 | set( _bitcoin_consensus_MSG_STATUS "STATUS" ) 30 | endif() 31 | 32 | set( bitcoin_consensus_FOUND false ) 33 | message( ${_bitcoin_consensus_MSG_STATUS} "MSVC environment detection for 'bitcoin-consensus' not currently supported." ) 34 | else () 35 | # required 36 | if ( Bitcoin-Consensus_FIND_REQUIRED ) 37 | set( _bitcoin_consensus_REQUIRED "REQUIRED" ) 38 | endif() 39 | 40 | # quiet 41 | if ( Bitcoin-Consensus_FIND_QUIETLY ) 42 | set( _bitcoin_consensus_QUIET "QUIET" ) 43 | endif() 44 | 45 | # modulespec 46 | if ( Bitcoin-Consensus_FIND_VERSION_COUNT EQUAL 0 ) 47 | set( _bitcoin_consensus_MODULE_SPEC "libbitcoin-consensus" ) 48 | else () 49 | if ( Bitcoin-Consensus_FIND_VERSION_EXACT ) 50 | set( _bitcoin_consensus_MODULE_SPEC_OP "=" ) 51 | else () 52 | set( _bitcoin_consensus_MODULE_SPEC_OP ">=" ) 53 | endif() 54 | 55 | set( _bitcoin_consensus_MODULE_SPEC "libbitcoin-consensus ${_bitcoin_consensus_MODULE_SPEC_OP} ${Bitcoin-Consensus_FIND_VERSION}" ) 56 | endif() 57 | 58 | pkg_check_modules( bitcoin_consensus ${_bitcoin_consensus_REQUIRED} ${_bitcoin_consensus_QUIET} "${_bitcoin_consensus_MODULE_SPEC}" ) 59 | set( bitcoin_consensus_PKG "${_bitcoin_consensus_MODULE_SPEC}" ) 60 | endif() 61 | -------------------------------------------------------------------------------- /builds/cmake/modules/FindBitcoin-Database.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2014-2025 libbitcoin-blockchain developers (see COPYING). 3 | # 4 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | # 6 | ############################################################################### 7 | # FindBitcoin-Database 8 | # 9 | # Use this module by invoking find_package with the form:: 10 | # 11 | # find_package( Bitcoin-Database 12 | # [version] # Minimum version 13 | # [REQUIRED] # Fail with error if bitcoin-database is not found 14 | # ) 15 | # 16 | # Defines the following for use: 17 | # 18 | # bitcoin_database_FOUND - true if headers and requested libraries were found 19 | # bitcoin_database_INCLUDE_DIRS - include directories for bitcoin-database libraries 20 | # bitcoin_database_LIBRARY_DIRS - link directories for bitcoin-database libraries 21 | # bitcoin_database_LIBRARIES - bitcoin-database libraries to be linked 22 | # bitcoin_database_PKG - bitcoin-database pkg-config package specification. 23 | # 24 | 25 | if (MSVC) 26 | if ( Bitcoin-Database_FIND_REQUIRED ) 27 | set( _bitcoin_database_MSG_STATUS "SEND_ERROR" ) 28 | else () 29 | set( _bitcoin_database_MSG_STATUS "STATUS" ) 30 | endif() 31 | 32 | set( bitcoin_database_FOUND false ) 33 | message( ${_bitcoin_database_MSG_STATUS} "MSVC environment detection for 'bitcoin-database' not currently supported." ) 34 | else () 35 | # required 36 | if ( Bitcoin-Database_FIND_REQUIRED ) 37 | set( _bitcoin_database_REQUIRED "REQUIRED" ) 38 | endif() 39 | 40 | # quiet 41 | if ( Bitcoin-Database_FIND_QUIETLY ) 42 | set( _bitcoin_database_QUIET "QUIET" ) 43 | endif() 44 | 45 | # modulespec 46 | if ( Bitcoin-Database_FIND_VERSION_COUNT EQUAL 0 ) 47 | set( _bitcoin_database_MODULE_SPEC "libbitcoin-database" ) 48 | else () 49 | if ( Bitcoin-Database_FIND_VERSION_EXACT ) 50 | set( _bitcoin_database_MODULE_SPEC_OP "=" ) 51 | else () 52 | set( _bitcoin_database_MODULE_SPEC_OP ">=" ) 53 | endif() 54 | 55 | set( _bitcoin_database_MODULE_SPEC "libbitcoin-database ${_bitcoin_database_MODULE_SPEC_OP} ${Bitcoin-Database_FIND_VERSION}" ) 56 | endif() 57 | 58 | pkg_check_modules( bitcoin_database ${_bitcoin_database_REQUIRED} ${_bitcoin_database_QUIET} "${_bitcoin_database_MODULE_SPEC}" ) 59 | set( bitcoin_database_PKG "${_bitcoin_database_MODULE_SPEC}" ) 60 | endif() 61 | -------------------------------------------------------------------------------- /builds/cmake/modules/FindBitcoin-Network.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2014-2025 libbitcoin-node developers (see COPYING). 3 | # 4 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | # 6 | ############################################################################### 7 | # FindBitcoin-Network 8 | # 9 | # Use this module by invoking find_package with the form:: 10 | # 11 | # find_package( Bitcoin-Network 12 | # [version] # Minimum version 13 | # [REQUIRED] # Fail with error if bitcoin-network is not found 14 | # ) 15 | # 16 | # Defines the following for use: 17 | # 18 | # bitcoin_network_FOUND - true if headers and requested libraries were found 19 | # bitcoin_network_INCLUDE_DIRS - include directories for bitcoin-network libraries 20 | # bitcoin_network_LIBRARY_DIRS - link directories for bitcoin-network libraries 21 | # bitcoin_network_LIBRARIES - bitcoin-network libraries to be linked 22 | # bitcoin_network_PKG - bitcoin-network pkg-config package specification. 23 | # 24 | 25 | if (MSVC) 26 | if ( Bitcoin-Network_FIND_REQUIRED ) 27 | set( _bitcoin_network_MSG_STATUS "SEND_ERROR" ) 28 | else () 29 | set( _bitcoin_network_MSG_STATUS "STATUS" ) 30 | endif() 31 | 32 | set( bitcoin_network_FOUND false ) 33 | message( ${_bitcoin_network_MSG_STATUS} "MSVC environment detection for 'bitcoin-network' not currently supported." ) 34 | else () 35 | # required 36 | if ( Bitcoin-Network_FIND_REQUIRED ) 37 | set( _bitcoin_network_REQUIRED "REQUIRED" ) 38 | endif() 39 | 40 | # quiet 41 | if ( Bitcoin-Network_FIND_QUIETLY ) 42 | set( _bitcoin_network_QUIET "QUIET" ) 43 | endif() 44 | 45 | # modulespec 46 | if ( Bitcoin-Network_FIND_VERSION_COUNT EQUAL 0 ) 47 | set( _bitcoin_network_MODULE_SPEC "libbitcoin-network" ) 48 | else () 49 | if ( Bitcoin-Network_FIND_VERSION_EXACT ) 50 | set( _bitcoin_network_MODULE_SPEC_OP "=" ) 51 | else () 52 | set( _bitcoin_network_MODULE_SPEC_OP ">=" ) 53 | endif() 54 | 55 | set( _bitcoin_network_MODULE_SPEC "libbitcoin-network ${_bitcoin_network_MODULE_SPEC_OP} ${Bitcoin-Network_FIND_VERSION}" ) 56 | endif() 57 | 58 | pkg_check_modules( bitcoin_network ${_bitcoin_network_REQUIRED} ${_bitcoin_network_QUIET} "${_bitcoin_network_MODULE_SPEC}" ) 59 | set( bitcoin_network_PKG "${_bitcoin_network_MODULE_SPEC}" ) 60 | endif() 61 | -------------------------------------------------------------------------------- /builds/msvc/.gitignore: -------------------------------------------------------------------------------- 1 | *.bin 2 | *.json 3 | *.suo 4 | *.opensdf 5 | *.sdf 6 | *.log 7 | *.aps 8 | *.user 9 | *.ipch 10 | *.VC.* -------------------------------------------------------------------------------- /builds/msvc/build/build_all.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | CALL nuget_all.bat 3 | ECHO. 4 | CALL build_base.bat vs2022 libbitcoin-node "Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build" 5 | CALL build_base.bat vs2019 libbitcoin-node "Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build" 6 | CALL build_base.bat vs2017 libbitcoin-node "Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build" 7 | REM CALL build_base.bat vs2015 libbitcoin-node "Microsoft Visual Studio 14.0\VC" 8 | REM CALL build_base.bat vs2013 libbitcoin-node "Microsoft Visual Studio 12.0\VC" 9 | PAUSE 10 | -------------------------------------------------------------------------------- /builds/msvc/build/build_base.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM Usage: [buildbase.bat vs2017 libbitcoin "Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"] 3 | REM Usage: [buildbase.bat vs2015 libbitcoin "Microsoft Visual Studio 14.0\VC"] 4 | REM Usage: [buildbase.bat vs2013 libbitcoin "Microsoft Visual Studio 12.0\VC"] 5 | 6 | SET studio=%1 7 | SET project=%2 8 | SET version=%~3 9 | 10 | SET log=%studio%.log 11 | SET solution=..\%studio%\%project%.sln 12 | SET tools=%version%\vcvarsall.bat 13 | SET environment=%programfiles(x86)%\%tools% 14 | 15 | IF NOT EXIST "%environment%" SET environment=%programfiles%\%tools% 16 | IF NOT EXIST "%environment%" GOTO no_tools 17 | 18 | ECHO Building: %solution% 19 | 20 | CALL "%environment%" x86 > nul 21 | ECHO Platform=x86 22 | 23 | ECHO Configuration=StaticDebug 24 | msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=Win32 %solution% >> %log% 25 | IF errorlevel 1 GOTO error 26 | ECHO Configuration=StaticRelease 27 | msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=Win32 %solution% >> %log% 28 | IF errorlevel 1 GOTO error 29 | 30 | CALL "%environment%" x86_amd64 > nul 31 | ECHO Platform=x64 32 | 33 | ECHO Configuration=StaticDebug 34 | msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=x64 %solution% >> %log% 35 | IF errorlevel 1 GOTO error 36 | ECHO Configuration=StaticRelease 37 | msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=x64 %solution% >> %log% 38 | IF errorlevel 1 GOTO error 39 | 40 | ECHO Complete: %solution% 41 | GOTO end 42 | 43 | :error 44 | ECHO *** ERROR, build terminated early, see: %log% 45 | GOTO end 46 | 47 | :no_tools 48 | ECHO *** ERROR, build tools not found: %tools% 49 | 50 | :end 51 | 52 | -------------------------------------------------------------------------------- /builds/msvc/build/nuget_all.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | ECHO Downloading libbitcoin vs2022 dependencies from NuGet 3 | CALL nuget.exe install ..\vs2022\libbitcoin-node\packages.config 4 | CALL nuget.exe install ..\vs2022\libbitcoin-node-test\packages.config 5 | ECHO. 6 | ECHO Downloading libbitcoin vs2019 dependencies from NuGet 7 | CALL nuget.exe install ..\vs2019\libbitcoin-node\packages.config 8 | CALL nuget.exe install ..\vs2019\libbitcoin-node-test\packages.config 9 | ECHO. 10 | ECHO Downloading libbitcoin vs2017 dependencies from NuGet 11 | CALL nuget.exe install ..\vs2017\libbitcoin-node\packages.config 12 | CALL nuget.exe install ..\vs2017\libbitcoin-node-test\packages.config -------------------------------------------------------------------------------- /builds/msvc/debug.natvis: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | { m_backend } 13 | 14 | 15 | 16 | 17 | { m_data } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /builds/msvc/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | -------------------------------------------------------------------------------- /builds/msvc/properties/Arm.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>ARM32 Settings 6 | 7 | 8 | 9 | 10 | 13 | WIN32;_WIN32;_ARM_;%(PreprocessorDefinitions) 14 | 15 | 16 | MachineARM 17 | 18 | 19 | /MACHINE:ARM %(AdditionalOptions) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /builds/msvc/properties/Arm64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>ARM64 Settings 6 | 7 | 8 | 9 | 10 | 13 | WIN32;_WIN32;_ARM64;%(PreprocessorDefinitions) 14 | 15 | 16 | MachineARM64 17 | 18 | 19 | /MACHINE:ARM64 %(AdditionalOptions) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /builds/msvc/properties/Common.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Common Settings 6 | Unicode 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | x64 15 | 16 | 17 | 18 | 19 | UNICODE;_UNICODE;%(PreprocessorDefinitions) 20 | 21 | 22 | 23 | Level4 24 | false 25 | false 26 | true 27 | 28 | 29 | 30 | /Zc:__cplusplus %(AdditionalOptions) 31 | true 32 | true 33 | false 34 | false 35 | stdc11 36 | stdcpp14 37 | stdcpp17 38 | stdcpp20 39 | false 40 | true 41 | true 42 | 43 | 44 | 45 | 46 | Level4 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /builds/msvc/properties/DLL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Dynamic Library 6 | dynamic 7 | .dll 8 | 9 | 10 | 11 | 12 | _DLL;_WINDLL;%(PreprocessorDefinitions) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /builds/msvc/properties/Debug.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <_PropertySheetDisplayName>Debug Settings 10 | Debug 11 | 12 | 13 | 14 | 15 | 16 | EnableFastChecks 17 | ProgramDatabase 18 | true 19 | true 20 | Disabled 21 | _DEBUG;%(PreprocessorDefinitions) 22 | 23 | 24 | _DEBUG;%(PreprocessorDefinitions) 25 | 26 | 27 | true 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugDEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Debug Dynamic 6 | dynamic 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDebugDLL 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugDLL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Dynamic Debug Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreadedDebugDLL 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugLEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Debug Link Time Code Generation 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDebug 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugLIB.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Debug Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreadedDebug 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugLTCG.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Debug Link Time Code Generation Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreadedDebug 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugSEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Debug Static 6 | static 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDebug 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/EXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Application 6 | true 7 | 8 | 9 | 10 | 11 | _CONSOLE;%(PreprocessorDefinitions) 12 | 13 | 14 | Console 15 | 16 | 17 | -------------------------------------------------------------------------------- /builds/msvc/properties/LIB.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Library 6 | static 7 | .lib 8 | 9 | 10 | 11 | 12 | _LIB;%(PreprocessorDefinitions) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /builds/msvc/properties/LTCG.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Link Time Code Generation Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /builds/msvc/properties/Link.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Link Time Code Generation Settings 6 | ltcg 7 | 8 | 9 | 10 | 11 | true 12 | 13 | 14 | UseLinkTimeCodeGeneration 15 | 16 | 17 | true 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /builds/msvc/properties/Messages.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Build Messages 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /builds/msvc/properties/Output.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Output Settings 6 | 7 | $(ProjectDir)..\..\ 8 | $(ProjectDir)..\..\..\..\ 9 | $(ProjectDir)..\..\..\..\..\ 10 | $(ProjectDir)..\..\..\..\bin\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ 11 | $(ProjectDir)..\..\..\..\obj\$(TargetName)\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ 12 | $(OutDir) 13 | $(TargetName) 14 | $(TargetDir)$(TargetName)$(TargetExt) 15 | 16 | 17 | 18 | 19 | $(OutDir)$(TargetName).lib 20 | 21 | 22 | $(OutDir)$(TargetName).log 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /builds/msvc/properties/Release.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <_PropertySheetDisplayName>Release Settings 10 | Release 11 | false 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | false 20 | 21 | 22 | false 23 | true 24 | true 25 | Speed 26 | true 27 | AnySuitable 28 | true 29 | true 30 | MaxSpeed 31 | 32 | 33 | 34 | 35 | AdvancedVectorExtensions2 36 | 37 | 38 | ProgramDatabase 39 | true 40 | NDEBUG;%(PreprocessorDefinitions) 41 | 42 | 43 | NDEBUG;%(PreprocessorDefinitions) 44 | 45 | 46 | true 47 | true 48 | true 49 | 50 | 51 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseDEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Release Dynamic 6 | dynamic 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDLL 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseDLL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Dynamic Release Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreadedDLL 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseLEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Release Link Time Code Generation 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreaded 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseLIB.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Release Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreaded 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseLTCG.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Release Link Time Code Generation Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreaded 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseSEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Release Static 6 | static 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreaded 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/Win32.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>x86 Settings 6 | 7 | 8 | 9 | 10 | WIN32;_WIN32;%(PreprocessorDefinitions) 11 | 12 | 13 | MachineX86 14 | 15 | 16 | /MACHINE:X86 %(AdditionalOptions) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>x64 Settings 6 | 7 | 8 | 9 | 10 | 13 | WIN32;_WIN32;WIN64;_WIN64;%(PreprocessorDefinitions) 14 | 15 | 16 | MachineX64 17 | 18 | 19 | /MACHINE:X64 %(AdditionalOptions) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /builds/msvc/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libbitcoin/libbitcoin-node/a6eff7a34d5bda27d3dc66c4b573205a920a8723/builds/msvc/resource.h -------------------------------------------------------------------------------- /builds/msvc/resource.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libbitcoin/libbitcoin-node/a6eff7a34d5bda27d3dc66c4b573205a920a8723/builds/msvc/resource.rc -------------------------------------------------------------------------------- /builds/msvc/vs2022/bn/bn.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Bitcoin Node Console Application 6 | AllRules.ruleset 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | $(RepoRoot)include\;%(AdditionalIncludeDirectories) 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | ..\..\..\..\..\.nuget\packages\ 30 | 31 | 32 | 33 | dynamic 34 | dynamic 35 | dynamic 36 | dynamic 37 | dynamic 38 | 39 | 40 | ltcg 41 | ltcg 42 | ltcg 43 | ltcg 44 | ltcg 45 | 46 | 47 | static 48 | static 49 | static 50 | static 51 | static 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/bn/bn.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | {D3404804-C83F-46CE-0000-000000000001} 12 | 13 | 14 | {D3404804-C83F-46CE-0000-000000000000} 15 | 16 | 17 | 18 | 19 | src 20 | 21 | 22 | src 23 | 24 | 25 | src 26 | 27 | 28 | src 29 | 30 | 31 | src 32 | 33 | 34 | src 35 | 36 | 37 | src 38 | 39 | 40 | src 41 | 42 | 43 | src 44 | 45 | 46 | src 47 | 48 | 49 | src 50 | 51 | 52 | src 53 | 54 | 55 | src 56 | 57 | 58 | 59 | 60 | src 61 | 62 | 63 | src 64 | 65 | 66 | src 67 | 68 | 69 | resource 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | resource 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/bn/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-database.import.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Libbitcoin Database Import Settings 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | $(ProjectDir)..\..\..\..\..\libbitcoin-database\include\;%(AdditionalIncludeDirectories) 19 | BCD_STATIC;%(PreprocessorDefinitions) 20 | 21 | 22 | libbitcoin-database.lib;%(AdditionalDependencies) 23 | 24 | 25 | 26 | $(ProjectDir)..\..\..\..\..\libbitcoin-database\bin\$(PlatformName)\Debug\$(PlatformToolset)\$(Linkage-libbitcoin-database)\; 27 | $(ProjectDir)..\..\..\..\..\libbitcoin-database\obj\libbitcoin-database\$(PlatformName)\Debug\$(PlatformToolset)\$(Linkage-libbitcoin-database)\;%(AdditionalLibraryDirectories) 28 | 29 | 30 | $(ProjectDir)..\..\..\..\..\libbitcoin-database\bin\$(PlatformName)\Release\$(PlatformToolset)\$(Linkage-libbitcoin-database)\; 31 | $(ProjectDir)..\..\..\..\..\libbitcoin-database\obj\libbitcoin-database\$(PlatformName)\Release\$(PlatformToolset)\$(Linkage-libbitcoin-database)\;%(AdditionalLibraryDirectories) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-database.import.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-network.import.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Libbitcoin Network Import Settings 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | $(ProjectDir)..\..\..\..\..\libbitcoin-network\include\;%(AdditionalIncludeDirectories) 19 | BCT_STATIC;%(PreprocessorDefinitions) 20 | 21 | 22 | libbitcoin-network.lib;%(AdditionalDependencies) 23 | 24 | 25 | 26 | $(ProjectDir)..\..\..\..\..\libbitcoin-network\bin\$(PlatformName)\Debug\$(PlatformToolset)\$(Linkage-libbitcoin-network)\; 27 | $(ProjectDir)..\..\..\..\..\libbitcoin-network\obj\libbitcoin-network\$(PlatformName)\Debug\$(PlatformToolset)\$(Linkage-libbitcoin-network)\;%(AdditionalLibraryDirectories) 28 | 29 | 30 | $(ProjectDir)..\..\..\..\..\libbitcoin-network\bin\$(PlatformName)\Release\$(PlatformToolset)\$(Linkage-libbitcoin-network)\; 31 | $(ProjectDir)..\..\..\..\..\libbitcoin-network\obj\libbitcoin-network\$(PlatformName)\Release\$(PlatformToolset)\$(Linkage-libbitcoin-network)\;%(AdditionalLibraryDirectories) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-network.import.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-node-test/libbitcoin-node-test.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Libbitcoin Node Test Common Settings 6 | AllRules.ruleset 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | false 15 | 16 | 17 | "$(TargetPath)" --log_level=warning --run_test=* --show_progress=no --build_info=yes 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ..\..\..\..\..\.nuget\packages\ 32 | 33 | 34 | 35 | dynamic 36 | dynamic 37 | dynamic 38 | dynamic 39 | dynamic 40 | 41 | 42 | static ltcg 43 | ltcg 44 | ltcg 45 | ltcg 46 | ltcg 47 | 48 | 49 | static 50 | static 51 | static 52 | static 53 | static 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-node-test/libbitcoin-node-test.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | {4BD50864-D3BC-4F64-0000-000000000000} 12 | 13 | 14 | {4BD50864-D3BC-4F64-0000-000000000001} 15 | 16 | 17 | {4BD50864-D3BC-4F64-0000-000000000002} 18 | 19 | 20 | {4BD50864-D3BC-4F64-0000-000000000003} 21 | 22 | 23 | 24 | 25 | src 26 | 27 | 28 | src 29 | 30 | 31 | src\chasers 32 | 33 | 34 | src\chasers 35 | 36 | 37 | src\chasers 38 | 39 | 40 | src\chasers 41 | 42 | 43 | src\chasers 44 | 45 | 46 | src\chasers 47 | 48 | 49 | src\chasers 50 | 51 | 52 | src\chasers 53 | 54 | 55 | src 56 | 57 | 58 | src 59 | 60 | 61 | src 62 | 63 | 64 | src 65 | 66 | 67 | src 68 | 69 | 70 | src\protocols 71 | 72 | 73 | src\sessions 74 | 75 | 76 | src 77 | 78 | 79 | src 80 | 81 | 82 | 83 | 84 | src 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-node-test/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-node.import.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Libbitcoin Node Import Settings 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | $(ProjectDir)..\..\..\..\..\libbitcoin-node\include\;%(AdditionalIncludeDirectories) 19 | BCN_STATIC;%(PreprocessorDefinitions) 20 | 21 | 22 | libbitcoin-node.lib;%(AdditionalDependencies) 23 | 24 | 25 | 26 | $(ProjectDir)..\..\..\..\..\libbitcoin-node\bin\$(PlatformName)\Debug\$(PlatformToolset)\$(Linkage-libbitcoin-node)\; 27 | $(ProjectDir)..\..\..\..\..\libbitcoin-node\obj\libbitcoin-node\$(PlatformName)\Debug\$(PlatformToolset)\$(Linkage-libbitcoin-node)\;%(AdditionalLibraryDirectories) 28 | 29 | 30 | $(ProjectDir)..\..\..\..\..\libbitcoin-node\bin\$(PlatformName)\Release\$(PlatformToolset)\$(Linkage-libbitcoin-node)\; 31 | $(ProjectDir)..\..\..\..\..\libbitcoin-node\obj\libbitcoin-node\$(PlatformName)\Release\$(PlatformToolset)\$(Linkage-libbitcoin-node)\;%(AdditionalLibraryDirectories) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-node.import.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Libbitcoin Node Library Common Settings 6 | AllRules.ruleset 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | $(RepoRoot)include\;%(AdditionalIncludeDirectories) 21 | false 22 | BCN_DLL;%(PreprocessorDefinitions) 23 | BCN_STATIC;%(PreprocessorDefinitions) 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | ..\..\..\..\..\.nuget\packages\ 37 | 38 | 39 | 40 | dynamic 41 | dynamic 42 | dynamic 43 | dynamic 44 | 45 | 46 | ltcg 47 | ltcg 48 | ltcg 49 | ltcg 50 | 51 | 52 | static 53 | static 54 | static 55 | static 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-node/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /builds/msvc/vs2022/libbitcoin-system.import.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 43 | 44 | -------------------------------------------------------------------------------- /builds/vscode/node.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "../../../libbitcoin-system" 5 | }, 6 | { 7 | "path": "../../../libbitcoin-network" 8 | }, 9 | { 10 | "path": "../../../libbitcoin-database" 11 | }, 12 | { 13 | "path": "../../../libbitcoin-node" 14 | } 15 | ], 16 | "settings": {} 17 | } 18 | -------------------------------------------------------------------------------- /console/executor_events.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "executor.hpp" 20 | 21 | #include 22 | #include 23 | 24 | namespace libbitcoin { 25 | namespace node { 26 | 27 | const std::unordered_map executor::fired_ 28 | { 29 | { events::header_archived, "header_archived....." }, 30 | { events::header_organized, "header_organized...." }, 31 | { events::header_reorganized, "header_reorganized.." }, 32 | 33 | { events::block_archived, "block_archived......" }, 34 | { events::block_buffered, "block_buffered......" }, 35 | { events::block_validated, "block_validated....." }, 36 | { events::block_confirmed, "block_confirmed....." }, 37 | { events::block_unconfirmable, "block_unconfirmable." }, 38 | { events::validate_bypassed, "validate_bypassed..." }, 39 | { events::confirm_bypassed, "confirm_bypassed...." }, 40 | 41 | { events::tx_archived, "tx_archived........." }, 42 | { events::tx_validated, "tx_validated........" }, 43 | { events::tx_invalidated, "tx_invalidated......" }, 44 | 45 | { events::block_organized, "block_organized....." }, 46 | { events::block_reorganized, "block_reorganized..." }, 47 | 48 | { events::template_issued, "template_issued....." }, 49 | 50 | { events::snapshot_span, "snapshot_span......." } 51 | }; 52 | 53 | // Events. 54 | // ---------------------------------------------------------------------------- 55 | 56 | // TODO: throws, handle failure. 57 | system::ofstream executor::create_event_sink() const 58 | { 59 | // Standard file name, within the [node].path directory. 60 | return { metadata_.configured.log.events_file() }; 61 | } 62 | 63 | void executor::subscribe_events(std::ostream& sink) 64 | { 65 | using namespace network; 66 | using namespace std::chrono; 67 | 68 | log_.subscribe_events 69 | ( 70 | [&sink, start = logger::now()](const code& ec, uint8_t event_, 71 | uint64_t value, const logger::time& point) 72 | { 73 | if (ec) 74 | return false; 75 | 76 | const auto time = duration_cast(point - start).count(); 77 | sink << fired_.at(event_) << " " << value << " " << time << std::endl; 78 | return true; 79 | } 80 | ); 81 | } 82 | 83 | } // namespace node 84 | } // namespace libbitcoin 85 | -------------------------------------------------------------------------------- /console/libbitcoin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libbitcoin/libbitcoin-node/a6eff7a34d5bda27d3dc66c4b573205a920a8723/console/libbitcoin.ico -------------------------------------------------------------------------------- /console/stack_trace.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_STACK_TRACE_HPP 20 | #define LIBBITCOIN_STACK_TRACE_HPP 21 | 22 | #include 23 | 24 | // This is some temporary code to explore emission of win32 stack dump. 25 | #if defined(HAVE_MSC) 26 | 27 | #include 28 | 29 | DWORD dump_stack_trace(unsigned code, EXCEPTION_POINTERS* exception) THROWS; 30 | 31 | #endif 32 | #endif 33 | -------------------------------------------------------------------------------- /data/bn: -------------------------------------------------------------------------------- 1 | # 2 | # Command-line completion for bn. 3 | # Listed options are currently incomplete. 4 | # 5 | _bn() 6 | { 7 | local current="${COMP_WORDS[COMP_CWORD]}" 8 | local options=" --config --help --newstore --settings --version -c -h -n -s -v" 9 | 10 | COMPREPLY=( `compgen -W "$options" -- $current` ) 11 | } 12 | complete -F _bn bn 13 | -------------------------------------------------------------------------------- /include/bitcoin/node.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014-2025 libbitcoin-node developers (see COPYING). 3 | // 4 | // GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | #ifndef LIBBITCOIN_NODE_HPP 8 | #define LIBBITCOIN_NODE_HPP 9 | 10 | /** 11 | * API Users: Include only this header. Direct use of other headers is fragile 12 | * and unsupported as header organization is subject to change. 13 | * 14 | * Maintainers: Do not include this header internal to this library. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/bitcoin/node/block_memory.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_BLOCK_MEMORY_HPP 20 | #define LIBBITCOIN_NODE_BLOCK_MEMORY_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | namespace node { 29 | 30 | /// Thread SAFE linked-linear arena allocator. 31 | class BCN_API block_memory 32 | : public network::memory 33 | { 34 | public: 35 | DELETE_COPY_MOVE_DESTRUCT(block_memory); 36 | 37 | /// Per thread multiple of wire size for each linear allocation chunk. 38 | /// Returns default_arena if multiple is zero or threads exceeded. 39 | block_memory(size_t multiple, size_t threads) NOEXCEPT; 40 | 41 | /// Each thread obtains an arena. 42 | arena* get_arena() NOEXCEPT override; 43 | 44 | protected: 45 | // This is thread safe. 46 | std::atomic_size_t count_{ zero }; 47 | 48 | // This is protected by constructor init and thread_local indexation. 49 | std::vector arenas_{}; 50 | }; 51 | 52 | } // namespace node 53 | } // namespace libbitcoin 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_block.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_BLOCK_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_BLOCK_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class full_node; 30 | 31 | /// Chase down stronger block branches for the confirmed chain. 32 | /// Weak branches are retained in a hash table if not store populated. 33 | /// Strong branches reorganize the candidate chain and fire the 'connect' event. 34 | class BCN_API chaser_block 35 | : public chaser_organize 36 | { 37 | public: 38 | DELETE_COPY_MOVE_DESTRUCT(chaser_block); 39 | 40 | chaser_block(full_node& node) NOEXCEPT; 41 | 42 | protected: 43 | /// Get header from Block instance. 44 | const system::chain::header& get_header( 45 | const system::chain::block& block) const NOEXCEPT override; 46 | 47 | /// Query store for const pointer to Block instance by candidate height. 48 | bool get_block(system::chain::block::cptr& out, 49 | const header_link& link) const NOEXCEPT override; 50 | 51 | /// Determine if Block is a duplicate (success for not duplicate). 52 | code duplicate(size_t& height, 53 | const system::hash_digest& hash) const NOEXCEPT override; 54 | 55 | /// Determine if Block is valid. 56 | code validate(const system::chain::block& block, 57 | const chain_state& state) const NOEXCEPT override; 58 | 59 | /// Determine if state is top of a storable branch (always true). 60 | bool is_storable(const chain_state& state) const NOEXCEPT override; 61 | 62 | /// True if Block is on a milestone-covered branch. 63 | bool is_under_milestone(size_t height) const NOEXCEPT override; 64 | 65 | /// Milestone tracking, true if updated. 66 | bool update_milestone(const system::chain::header& header, 67 | size_t height, size_t branch_point) NOEXCEPT override; 68 | 69 | private: 70 | void set_prevout(const system::chain::input& input) const NOEXCEPT; 71 | bool populate(const system::chain::block& block) const NOEXCEPT; 72 | }; 73 | 74 | } // namespace node 75 | } // namespace libbitcoin 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_confirm.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_CONFIRM_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_CONFIRM_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class full_node; 30 | 31 | /// Chase down valid blocks for confirmation. 32 | class BCN_API chaser_confirm 33 | : public chaser 34 | { 35 | public: 36 | DELETE_COPY_MOVE_DESTRUCT(chaser_confirm); 37 | 38 | chaser_confirm(full_node& node) NOEXCEPT; 39 | 40 | code start() NOEXCEPT override; 41 | 42 | protected: 43 | using header_link = database::header_link; 44 | using header_links = database::header_links; 45 | using header_states = database::header_states; 46 | 47 | virtual bool handle_event(const code& ec, chase event_, 48 | event_value value) NOEXCEPT; 49 | 50 | virtual void do_regressed(height_t branch_point) NOEXCEPT; 51 | virtual void do_validated(height_t height) NOEXCEPT; 52 | virtual void do_bumped(height_t height) NOEXCEPT; 53 | virtual void do_bump(height_t height) NOEXCEPT; 54 | 55 | virtual void reorganize(header_states& fork, size_t top, 56 | size_t fork_point) NOEXCEPT; 57 | virtual void organize(header_states& fork, const header_links& popped, 58 | size_t fork_point) NOEXCEPT; 59 | virtual bool confirm_block(const header_link& link, 60 | size_t height, const header_links& popped, size_t fork_point) NOEXCEPT; 61 | virtual bool complete_block(const code& ec, const header_link& link, 62 | size_t height, bool bypassed) NOEXCEPT; 63 | 64 | private: 65 | bool set_reorganized(const header_link& link, 66 | height_t confirmed_height) NOEXCEPT; 67 | bool set_organized(const header_link& link, 68 | height_t confirmed_height) NOEXCEPT; 69 | bool roll_back(const header_links& popped, size_t fork_point, 70 | size_t top) NOEXCEPT; 71 | 72 | // This is thread safe. 73 | const bool filter_; 74 | }; 75 | 76 | } // namespace node 77 | } // namespace libbitcoin 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_header.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_HEADER_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_HEADER_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class full_node; 30 | 31 | /// Chase down stronger header branches for the candidate chain. 32 | /// Weak branches are retained in a hash table if not store populated. 33 | /// Strong branches reorganize the candidate chain and fire the 'header' event. 34 | class BCN_API chaser_header 35 | : public chaser_organize 36 | { 37 | public: 38 | DELETE_COPY_MOVE_DESTRUCT(chaser_header); 39 | 40 | chaser_header(full_node& node) NOEXCEPT; 41 | 42 | /// Initialize chaser state. 43 | code start() NOEXCEPT override; 44 | 45 | protected: 46 | /// Get header from Block instance. 47 | const system::chain::header& get_header( 48 | const system::chain::header& header) const NOEXCEPT override; 49 | 50 | /// Query store for const pointer to Block instance by candidate height. 51 | bool get_block(system::chain::header::cptr& out, 52 | const header_link& link) const NOEXCEPT override; 53 | 54 | /// Determine if Block is a duplicate (success for not duplicate). 55 | code duplicate(size_t& height, 56 | const system::hash_digest& hash) const NOEXCEPT override; 57 | 58 | /// Determine if Block is valid. 59 | code validate(const system::chain::header& header, 60 | const chain_state& state) const NOEXCEPT override; 61 | 62 | /// Determine if state is top of a storable branch. 63 | bool is_storable(const chain_state& state) const NOEXCEPT override; 64 | 65 | /// True if Block is on a milestone-covered branch. 66 | bool is_under_milestone(size_t height) const NOEXCEPT override; 67 | 68 | /// Milestone tracking, true if updated. 69 | bool update_milestone(const system::chain::header& header, 70 | size_t height, size_t branch_point) NOEXCEPT override; 71 | 72 | private: 73 | bool is_checkpoint(const chain_state& state) const NOEXCEPT; 74 | bool is_milestone(const chain_state& state) const NOEXCEPT; 75 | bool is_current(const chain_state& state) const NOEXCEPT; 76 | bool is_hard(const chain_state& state) const NOEXCEPT; 77 | bool initialize_milestone() NOEXCEPT; 78 | 79 | // This is thread safe. 80 | const system::chain::checkpoint& milestone_; 81 | 82 | // This is protected by strand. 83 | size_t active_milestone_height_{}; 84 | }; 85 | 86 | } // namespace node 87 | } // namespace libbitcoin 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_snapshot.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_SNAPSHOT_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_SNAPSHOT_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class full_node; 30 | 31 | /// Perform automated snapshots. 32 | class BCN_API chaser_snapshot 33 | : public chaser 34 | { 35 | public: 36 | DELETE_COPY_MOVE_DESTRUCT(chaser_snapshot); 37 | 38 | chaser_snapshot(full_node& node) NOEXCEPT; 39 | 40 | code start() NOEXCEPT override; 41 | 42 | protected: 43 | virtual void do_archive(height_t height) NOEXCEPT; 44 | virtual void do_valid(height_t height) NOEXCEPT; 45 | virtual void do_confirm(height_t height) NOEXCEPT; 46 | virtual bool handle_event(const code& ec, chase event_, 47 | event_value value) NOEXCEPT; 48 | 49 | private: 50 | bool update_bytes() NOEXCEPT; 51 | bool update_valid(height_t height) NOEXCEPT; 52 | bool update_confirm(height_t height) NOEXCEPT; 53 | void do_snapshot(height_t height) NOEXCEPT; 54 | 55 | // These are thread safe. 56 | const uint64_t snapshot_bytes_; 57 | const size_t snapshot_valid_; 58 | const size_t snapshot_confirm_; 59 | const bool enabled_bytes_; 60 | const bool enabled_valid_; 61 | const bool enabled_confirm_; 62 | 63 | // These are protected by strand. 64 | uint64_t bytes_{}; 65 | size_t valid_{}; 66 | size_t confirm_{}; 67 | }; 68 | 69 | } // namespace node 70 | } // namespace libbitcoin 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_storage.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_STORAGE_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_STORAGE_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class full_node; 30 | 31 | /// Monitor storage capacity following a disk full condition. 32 | /// Clear disk full condition and restart network given increased capacity. 33 | class BCN_API chaser_storage 34 | : public chaser 35 | { 36 | public: 37 | DELETE_COPY_MOVE_DESTRUCT(chaser_storage); 38 | 39 | chaser_storage(full_node& node) NOEXCEPT; 40 | 41 | code start() NOEXCEPT override; 42 | void stopping(const code& ec) NOEXCEPT override; 43 | 44 | protected: 45 | virtual void do_reload() NOEXCEPT; 46 | virtual void do_space(size_t space) NOEXCEPT; 47 | virtual bool handle_event(const code& ec, chase event_, 48 | event_value value) NOEXCEPT; 49 | 50 | private: 51 | void do_stopping(const code& ec) NOEXCEPT; 52 | void handle_timer(const code& ec) NOEXCEPT; 53 | bool have_capacity() const NOEXCEPT; 54 | 55 | // This is thread safe. 56 | const std::filesystem::path store_; 57 | 58 | // This is protected by strand. 59 | network::deadline::ptr disk_timer_{}; 60 | }; 61 | 62 | } // namespace node 63 | } // namespace libbitcoin 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_template.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_TEMPLATE_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_TEMPLATE_HPP 21 | 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | class full_node; 29 | 30 | /// Construct template blocks upon modification of the transaction DAG. 31 | class BCN_API chaser_template 32 | : public chaser 33 | { 34 | public: 35 | DELETE_COPY_MOVE_DESTRUCT(chaser_template); 36 | 37 | chaser_template(full_node& node) NOEXCEPT; 38 | 39 | code start() NOEXCEPT override; 40 | 41 | protected: 42 | virtual bool handle_event(const code& ec, chase event_, 43 | event_value value) NOEXCEPT; 44 | 45 | virtual void do_transaction(transaction_t value) NOEXCEPT; 46 | }; 47 | 48 | } // namespace node 49 | } // namespace libbitcoin 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_transaction.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_TRANSACTION_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_TRANSACTION_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class full_node; 30 | 31 | /// Chase down unconfirmed transactions. 32 | class BCN_API chaser_transaction 33 | : public chaser 34 | { 35 | public: 36 | DELETE_COPY_MOVE_DESTRUCT(chaser_transaction); 37 | 38 | chaser_transaction(full_node& node) NOEXCEPT; 39 | 40 | code start() NOEXCEPT override; 41 | 42 | virtual void store(const system::chain::transaction::cptr& block) NOEXCEPT; 43 | 44 | protected: 45 | virtual bool handle_event(const code& ec, chase event_, 46 | event_value value) NOEXCEPT; 47 | 48 | virtual void do_confirmed(header_t link) NOEXCEPT; 49 | virtual void do_store( 50 | const system::chain::transaction::cptr& header) NOEXCEPT; 51 | }; 52 | 53 | } // namespace node 54 | } // namespace libbitcoin 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chaser_validate.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASER_VALIDATE_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASER_VALIDATE_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | namespace node { 30 | 31 | class full_node; 32 | 33 | /// Chase down blocks in the the candidate header chain for validation. 34 | class BCN_API chaser_validate 35 | : public chaser 36 | { 37 | public: 38 | DELETE_COPY_MOVE_DESTRUCT(chaser_validate); 39 | 40 | chaser_validate(full_node& node) NOEXCEPT; 41 | 42 | code start() NOEXCEPT override; 43 | void stopping(const code& ec) NOEXCEPT override; 44 | void stop() NOEXCEPT override; 45 | 46 | protected: 47 | typedef network::race_unity race; 48 | 49 | virtual bool handle_event(const code& ec, chase event_, 50 | event_value value) NOEXCEPT; 51 | 52 | virtual void do_regressed(height_t branch_point) NOEXCEPT; 53 | virtual void do_checked(height_t height) NOEXCEPT; 54 | virtual void do_bumped(height_t height) NOEXCEPT; 55 | virtual void do_bump(height_t height) NOEXCEPT; 56 | 57 | virtual void post_block(const database::header_link& link, 58 | bool bypass) NOEXCEPT; 59 | virtual void validate_block(const database::header_link& link, 60 | bool bypass) NOEXCEPT; 61 | virtual code validate(bool bypass, const system::chain::block& block, 62 | const database::header_link& link, 63 | const system::chain::context& ctx) NOEXCEPT; 64 | virtual code populate(bool bypass, const system::chain::block& block, 65 | const system::chain::context& ctx) NOEXCEPT; 66 | virtual void complete_block(const code& ec, 67 | const database::header_link& link, size_t height, 68 | bool bypassed) NOEXCEPT; 69 | 70 | // Override base class strand because it sits on the network thread pool. 71 | network::asio::strand& strand() NOEXCEPT override; 72 | bool stranded() const NOEXCEPT override; 73 | 74 | private: 75 | // This is protected by strand. 76 | network::threadpool threadpool_; 77 | 78 | // These are thread safe. 79 | std::atomic backlog_{}; 80 | network::asio::strand independent_strand_; 81 | const uint32_t subsidy_interval_; 82 | const uint64_t initial_subsidy_; 83 | const size_t maximum_backlog_; 84 | const bool filter_; 85 | }; 86 | 87 | } // namespace node 88 | } // namespace libbitcoin 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /include/bitcoin/node/chasers/chasers.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CHASERS_CHASERS_HPP 20 | #define LIBBITCOIN_NODE_CHASERS_CHASERS_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/bitcoin/node/configuration.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_CONFIGURATION_HPP 20 | #define LIBBITCOIN_NODE_CONFIGURATION_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | namespace node { 29 | 30 | /// Full node configuration, thread safe. 31 | class BCN_API configuration 32 | { 33 | public: 34 | DEFAULT_COPY_MOVE_DESTRUCT(configuration); 35 | 36 | configuration(system::chain::selection context) NOEXCEPT; 37 | 38 | /// Environment. 39 | std::filesystem::path file; 40 | 41 | /// Information. 42 | bool help{}; 43 | bool hardware{}; 44 | bool settings{}; 45 | bool version{}; 46 | 47 | /// Actions. 48 | bool newstore{}; 49 | bool backup{}; 50 | bool restore{}; 51 | 52 | /// Chain scans. 53 | bool flags{}; 54 | bool information{}; 55 | bool slabs{}; 56 | bool buckets{}; 57 | bool collisions{}; 58 | 59 | /// Ad-hoc Testing. 60 | bool test{}; 61 | bool write{}; 62 | 63 | /// Settings. 64 | log::settings log; 65 | node::settings node; 66 | network::settings network; 67 | database::settings database; 68 | system::settings bitcoin; 69 | }; 70 | 71 | } // namespace node 72 | } // namespace libbitcoin 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/bitcoin/node/error.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_ERROR_HPP 20 | #define LIBBITCOIN_NODE_ERROR_HPP 21 | 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | /// Alias system code. 29 | /// std::error_code "node" category holds node::error::error_t. 30 | typedef std::error_code code; 31 | 32 | namespace error { 33 | 34 | /// Asio failures are normalized to the error codes below. 35 | /// Stop by explicit call is mapped to channel_stopped or service_stopped 36 | /// depending on the context. Asio errors returned on cancel calls are ignored. 37 | enum error_t : uint8_t 38 | { 39 | /// general 40 | success, 41 | 42 | /// database 43 | store_uninitialized, 44 | store_reload, 45 | store_snapshot, 46 | 47 | /// network 48 | slow_channel, 49 | stalled_channel, 50 | exhausted_channel, 51 | sacrificed_channel, 52 | suspended_channel, 53 | suspended_service, 54 | 55 | /// blockchain 56 | orphan_block, 57 | orphan_header, 58 | duplicate_block, 59 | duplicate_header, 60 | 61 | /// faults (terminal, code error and store corruption assumed) 62 | protocol1, 63 | protocol2, 64 | header1, 65 | organize1, 66 | organize2, 67 | organize3, 68 | organize4, 69 | organize5, 70 | organize6, 71 | organize7, 72 | organize8, 73 | organize9, 74 | organize10, 75 | organize11, 76 | organize12, 77 | organize13, 78 | organize14, 79 | organize15, 80 | validate1, 81 | validate2, 82 | validate3, 83 | validate4, 84 | validate5, 85 | validate6, 86 | validate7, 87 | validate8, 88 | confirm1, 89 | confirm2, 90 | confirm3, 91 | confirm4, 92 | confirm5, 93 | confirm6, 94 | confirm7, 95 | confirm8, 96 | confirm9, 97 | confirm10, 98 | confirm11, 99 | confirm12, 100 | confirm13 101 | }; 102 | 103 | // No current need for error_code equivalence mapping. 104 | DECLARE_ERROR_T_CODE_CATEGORY(error); 105 | 106 | } // namespace error 107 | } // namespace node 108 | } // namespace libbitcoin 109 | 110 | DECLARE_STD_ERROR_REGISTRATION(bc::node::error::error) 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /include/bitcoin/node/events.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_EVENTS_HPP 20 | #define LIBBITCOIN_NODE_EVENTS_HPP 21 | 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | /// Reporting events. 29 | enum events : uint8_t 30 | { 31 | /// Candidate chain. 32 | header_archived, // header checked, accepted 33 | header_organized, // header pushed (previously archived) 34 | header_reorganized, // header popped 35 | 36 | /// Blocks. 37 | block_archived, // block checked 38 | block_buffered, // block buffered for validation 39 | block_validated, // block checked, accepted, connected 40 | block_confirmed, // block checked, accepted, connected, confirmable 41 | block_unconfirmable, // block invalid (after headers-first archive) 42 | validate_bypassed, // block checked, accepted [assumed] 43 | confirm_bypassed, // block checked, accepted, connected [assumed] 44 | 45 | /// Transactions. 46 | tx_archived, // unassociated tx checked, accepted, connected 47 | tx_validated, // associated tx checked, accepted, connected 48 | tx_invalidated, // associated tx invalid (after headers-first archive) 49 | 50 | /// Confirmed chain. 51 | block_organized, // block pushed (previously confirmable) 52 | block_reorganized, // block popped 53 | 54 | /// Mining. 55 | template_issued, // block template issued for mining 56 | 57 | /// Snapshot span. 58 | snapshot_span 59 | }; 60 | 61 | } // namespace node 62 | } // namespace libbitcoin 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/bitcoin/node/parser.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PARSER_HPP 20 | #define LIBBITCOIN_NODE_PARSER_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | // Not localizable. 27 | #define BN_HELP_VARIABLE "help" 28 | #define BN_HARDWARE_VARIABLE "hardware" 29 | #define BN_SETTINGS_VARIABLE "settings" 30 | #define BN_VERSION_VARIABLE "version" 31 | #define BN_NEWSTORE_VARIABLE "newstore" 32 | #define BN_BACKUP_VARIABLE "backup" 33 | #define BN_RESTORE_VARIABLE "restore" 34 | 35 | #define BN_FLAGS_VARIABLE "flags" 36 | #define BN_SLABS_VARIABLE "slabs" 37 | #define BN_BUCKETS_VARIABLE "buckets" 38 | #define BN_COLLISIONS_VARIABLE "collisions" 39 | #define BN_INFORMATION_VARIABLE "information" 40 | 41 | #define BN_READ_VARIABLE "test" 42 | #define BN_WRITE_VARIABLE "write" 43 | 44 | // This must be lower case but the env var part can be any case. 45 | #define BN_CONFIG_VARIABLE "config" 46 | 47 | // This must match the case of the env var. 48 | #define BN_ENVIRONMENT_VARIABLE_PREFIX "BN_" 49 | 50 | namespace libbitcoin { 51 | namespace node { 52 | 53 | /// Parse configurable values from environment variables, settings file, and 54 | /// command line positional and non-positional options. 55 | class BCN_API parser 56 | : public system::config::parser 57 | { 58 | public: 59 | parser(system::chain::selection context) NOEXCEPT; 60 | parser(const configuration& defaults) NOEXCEPT; 61 | 62 | /// Load command line options (named). 63 | virtual options_metadata load_options() THROWS; 64 | 65 | /// Load command line arguments (positional). 66 | virtual arguments_metadata load_arguments() THROWS; 67 | 68 | /// Load environment variable settings. 69 | virtual options_metadata load_environment() THROWS; 70 | 71 | /// Load configuration file settings. 72 | virtual options_metadata load_settings() THROWS; 73 | 74 | /// Parse all configuration into member settings. 75 | virtual bool parse(int argc, const char* argv[], 76 | std::ostream& error) THROWS; 77 | 78 | /// The populated configuration settings values. 79 | configuration configured; 80 | }; 81 | 82 | } // namespace node 83 | } // namespace libbitcoin 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_block_in.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_BLOCK_IN_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_BLOCK_IN_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | namespace node { 29 | 30 | class BCN_API protocol_block_in 31 | : public node::protocol, 32 | protected network::tracker 33 | { 34 | public: 35 | typedef std::shared_ptr ptr; 36 | using type_id = network::messages::inventory::type_id; 37 | 38 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 39 | template 40 | protocol_block_in(const SessionPtr& session, 41 | const channel_ptr& channel) NOEXCEPT 42 | : node::protocol(session, channel), 43 | network::tracker(session->log), 44 | block_type_(session->config().network.witness_node() ? 45 | type_id::witness_block : type_id::block) 46 | { 47 | } 48 | BC_POP_WARNING() 49 | 50 | /// Start/stop protocol (strand required). 51 | void start() NOEXCEPT override; 52 | 53 | protected: 54 | /// Squash duplicates and provide constant time retrieval. 55 | using hashmap = std::unordered_set; 56 | 57 | struct track 58 | { 59 | // TODO: optimize, default bucket count is around 8. 60 | hashmap ids{}; 61 | size_t announced{}; 62 | system::hash_digest last{}; 63 | }; 64 | 65 | /// Accept incoming inventory message. 66 | virtual bool handle_receive_inventory(const code& ec, 67 | const network::messages::inventory::cptr& message) NOEXCEPT; 68 | 69 | /// Accept incoming block message. 70 | virtual bool handle_receive_block(const code& ec, 71 | const network::messages::block::cptr& message) NOEXCEPT; 72 | virtual void handle_organize(const code& ec, size_t height, 73 | const system::chain::block::cptr& block_ptr) NOEXCEPT; 74 | 75 | private: 76 | static hashmap to_hashes( 77 | const network::messages::get_data& getter) NOEXCEPT; 78 | 79 | network::messages::get_blocks create_get_inventory() const NOEXCEPT; 80 | network::messages::get_blocks create_get_inventory( 81 | const system::hash_digest& last) const NOEXCEPT; 82 | network::messages::get_blocks create_get_inventory( 83 | system::hashes&& start_hashes) const NOEXCEPT; 84 | 85 | network::messages::get_data create_get_data( 86 | const network::messages::inventory& message) const NOEXCEPT; 87 | 88 | // This is protected by strand. 89 | track tracker_{}; 90 | 91 | // This is thread safe. 92 | const network::messages::inventory::type_id block_type_; 93 | }; 94 | 95 | } // namespace node 96 | } // namespace libbitcoin 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_block_out.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_BLOCK_OUT_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_BLOCK_OUT_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_block_out 30 | : public node::protocol, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_block_out(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | 44 | /// Start protocol (strand required). 45 | void start() NOEXCEPT override; 46 | }; 47 | 48 | } // namespace node 49 | } // namespace libbitcoin 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_header_in_31800.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_IN_31800_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_IN_31800_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_header_in_31800 30 | : public node::protocol, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_header_in_31800(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | 44 | /// Start protocol (strand required). 45 | void start() NOEXCEPT override; 46 | 47 | protected: 48 | virtual bool handle_receive_headers(const code& ec, 49 | const network::messages::headers::cptr& message) NOEXCEPT; 50 | virtual void handle_organize(const code& ec, size_t height, 51 | const system::chain::header::cptr& header_ptr) NOEXCEPT; 52 | virtual void complete() NOEXCEPT; 53 | 54 | private: 55 | network::messages::get_headers create_get_headers() const NOEXCEPT; 56 | network::messages::get_headers create_get_headers( 57 | const system::hash_digest& last) const NOEXCEPT; 58 | network::messages::get_headers create_get_headers( 59 | system::hashes&& start_hashes) const NOEXCEPT; 60 | }; 61 | 62 | } // namespace node 63 | } // namespace libbitcoin 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_header_in_70012.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_IN_70012_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_IN_70012_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_header_in_70012 30 | : public protocol_header_in_31800, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_header_in_70012(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol_header_in_31800(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | 44 | protected: 45 | /// Invoked when initial headers sync is complete. 46 | void complete() NOEXCEPT override; 47 | 48 | private: 49 | bool sent_{}; 50 | }; 51 | 52 | } // namespace node 53 | } // namespace libbitcoin 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_header_out_31800.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_OUT_31800_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_OUT_31800_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_header_out_31800 30 | : public node::protocol, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_header_out_31800(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | 44 | /// Start protocol (strand required). 45 | void start() NOEXCEPT override; 46 | 47 | protected: 48 | virtual bool handle_receive_get_headers(const code& ec, 49 | const network::messages::get_headers::cptr& message) NOEXCEPT; 50 | 51 | private: 52 | network::messages::headers create_headers( 53 | const network::messages::get_headers& locator) const NOEXCEPT; 54 | }; 55 | 56 | } // namespace node 57 | } // namespace libbitcoin 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_header_out_70012.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_OUT_70012_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_HEADER_OUT_70012_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_header_out_70012 30 | : public protocol_header_out_31800, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_header_out_70012(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol_header_out_31800(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | }; 44 | 45 | } // namespace node 46 | } // namespace libbitcoin 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_observer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_OBSERVER_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_OBSERVER_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_observer 30 | : public node::protocol, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_observer(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | 44 | /// Start/stop protocol (strand required). 45 | void start() NOEXCEPT override; 46 | void stopping(const code& ec) NOEXCEPT override; 47 | 48 | protected: 49 | /// Handle event subscription completion. 50 | virtual void handle_complete(const code& ec, object_key key) NOEXCEPT; 51 | 52 | /// Handle chaser events. 53 | virtual bool handle_event(const code& ec, chase event_, 54 | event_value value) NOEXCEPT; 55 | 56 | private: 57 | void do_handle_complete(const code& e) NOEXCEPT; 58 | }; 59 | 60 | } // namespace node 61 | } // namespace libbitcoin 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_performer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOL_PERFORMER_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOL_PERFORMER_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | /// Abstract base protocol for performance standard deviation measurement. 30 | class BCN_API protocol_performer 31 | : public node::protocol, 32 | protected network::tracker 33 | { 34 | public: 35 | virtual void start_performance() NOEXCEPT; 36 | virtual void pause_performance() NOEXCEPT; 37 | virtual void stop_performance() NOEXCEPT; 38 | virtual void count(size_t bytes) NOEXCEPT; 39 | 40 | protected: 41 | template 42 | protocol_performer(const SessionPtr& session, 43 | const channel_ptr& channel) NOEXCEPT 44 | : node::protocol(session, channel), 45 | network::tracker(session->log), 46 | deviation_(session->config().node.allowed_deviation > 0.0), 47 | enabled_(to_bool(session->config().node.sample_period_seconds)), 48 | performance_timer_(std::make_shared(session->log, 49 | channel->strand(), session->config().node.sample_period())) 50 | { 51 | } 52 | 53 | virtual bool is_idle() const NOEXCEPT = 0; 54 | 55 | private: 56 | void handle_performance_timer(const code& ec) NOEXCEPT; 57 | void handle_send_performance(const code& ec) NOEXCEPT; 58 | void do_handle_performance(const code& ec) NOEXCEPT; 59 | 60 | void send_performance(uint64_t rate) NOEXCEPT; 61 | 62 | // These are thread safe. 63 | const bool deviation_; 64 | const bool enabled_; 65 | 66 | // These are protected by strand. 67 | uint64_t bytes_{ zero }; 68 | network::steady_clock::time_point start_{}; 69 | network::deadline::ptr performance_timer_; 70 | }; 71 | 72 | } // namespace node 73 | } // namespace libbitcoin 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_transaction_in.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_TRANSACTION_IN_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_TRANSACTION_IN_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_transaction_in 30 | : public node::protocol, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_transaction_in(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | 44 | /// Start protocol (strand required). 45 | void start() NOEXCEPT override; 46 | }; 47 | 48 | } // namespace node 49 | } // namespace libbitcoin 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocol_transaction_out.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_TRANSACTION_OUT_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_TRANSACTION_OUT_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class BCN_API protocol_transaction_out 30 | : public node::protocol, 31 | protected network::tracker 32 | { 33 | public: 34 | typedef std::shared_ptr ptr; 35 | 36 | template 37 | protocol_transaction_out(const SessionPtr& session, 38 | const channel_ptr& channel) NOEXCEPT 39 | : node::protocol(session, channel), 40 | network::tracker(session->log) 41 | { 42 | } 43 | 44 | /// Start protocol (strand required). 45 | void start() NOEXCEPT override; 46 | }; 47 | 48 | } // namespace node 49 | } // namespace libbitcoin 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/bitcoin/node/protocols/protocols.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOLS_HPP 20 | #define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOLS_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/bitcoin/node/sessions/session_inbound.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_SESSIONS_SESSION_INBOUND_HPP 20 | #define LIBBITCOIN_NODE_SESSIONS_SESSION_INBOUND_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class session_inbound 30 | : public attach 31 | { 32 | public: 33 | typedef std::shared_ptr ptr; 34 | using base = attach; 35 | using base::base; 36 | }; 37 | 38 | } // namespace node 39 | } // namespace libbitcoin 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/bitcoin/node/sessions/session_manual.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_SESSIONS_SESSION_MANUAL_HPP 20 | #define LIBBITCOIN_NODE_SESSIONS_SESSION_MANUAL_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | class session_manual 30 | : public attach 31 | { 32 | public: 33 | typedef std::shared_ptr ptr; 34 | using base = attach; 35 | using base::base; 36 | }; 37 | 38 | } // namespace node 39 | } // namespace libbitcoin 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/bitcoin/node/sessions/session_outbound.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_SESSIONS_SESSION_OUTBOUND_HPP 20 | #define LIBBITCOIN_NODE_SESSIONS_SESSION_OUTBOUND_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | namespace node { 29 | 30 | class BCN_API session_outbound 31 | : public attach, 32 | protected network::tracker 33 | { 34 | public: 35 | typedef std::shared_ptr ptr; 36 | 37 | session_outbound(full_node& node, uint64_t identifier) NOEXCEPT; 38 | 39 | void start(network::result_handler&& handler) NOEXCEPT override; 40 | void performance(object_key channel, uint64_t speed, 41 | network::result_handler&& handler) NOEXCEPT override; 42 | 43 | protected: 44 | virtual bool handle_event(const code& ec, chase event_, 45 | event_value value) NOEXCEPT; 46 | virtual void do_starved(object_t self) NOEXCEPT; 47 | virtual void do_performance(object_key channel, uint64_t speed, 48 | const network::result_handler& handler) NOEXCEPT; 49 | 50 | private: 51 | static constexpr size_t minimum_for_standard_deviation = 3; 52 | 53 | // This is thread safe. 54 | const float allowed_deviation_; 55 | 56 | // This is protected by strand. 57 | // TODO: optimize, default bucket count is around 8. 58 | std::unordered_map speeds_{}; 59 | }; 60 | 61 | } // namespace node 62 | } // namespace libbitcoin 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/bitcoin/node/sessions/sessions.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_SESSIONS_SESSIONS_HPP 20 | #define LIBBITCOIN_NODE_SESSIONS_SESSIONS_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/bitcoin/node/settings.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_NODE_SETTINGS_HPP 20 | #define LIBBITCOIN_NODE_SETTINGS_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace log { 28 | 29 | /// [log] settings. 30 | class BCN_API settings 31 | { 32 | public: 33 | DEFAULT_COPY_MOVE_DESTRUCT(settings); 34 | 35 | settings() NOEXCEPT; 36 | settings(system::chain::selection context) NOEXCEPT; 37 | 38 | bool application; 39 | bool news; 40 | bool session; 41 | bool protocol; 42 | bool proxy; 43 | bool remote; 44 | bool fault; 45 | bool quitting; 46 | bool objects; 47 | bool verbose; 48 | 49 | uint32_t maximum_size; 50 | std::filesystem::path path; 51 | 52 | #if defined (HAVE_MSC) 53 | std::filesystem::path symbols; 54 | #endif 55 | 56 | virtual std::filesystem::path log_file1() const NOEXCEPT; 57 | virtual std::filesystem::path log_file2() const NOEXCEPT; 58 | virtual std::filesystem::path events_file() const NOEXCEPT; 59 | }; 60 | 61 | } // namespace log 62 | 63 | namespace node { 64 | 65 | /// [node] settings. 66 | class BCN_API settings 67 | { 68 | public: 69 | DEFAULT_COPY_MOVE_DESTRUCT(settings); 70 | 71 | settings() NOEXCEPT; 72 | settings(system::chain::selection context) NOEXCEPT; 73 | 74 | /// Properties. 75 | bool priority; 76 | bool headers_first; 77 | float allowed_deviation; 78 | uint16_t allocation_multiple; 79 | uint64_t snapshot_bytes; 80 | uint32_t snapshot_valid; 81 | uint32_t snapshot_confirm; 82 | uint32_t maximum_height; 83 | uint32_t maximum_concurrency; 84 | uint16_t sample_period_seconds; 85 | uint32_t currency_window_minutes; 86 | uint32_t threads; 87 | 88 | /// Helpers. 89 | virtual size_t threads_() const NOEXCEPT; 90 | virtual size_t maximum_height_() const NOEXCEPT; 91 | virtual size_t maximum_concurrency_() const NOEXCEPT; 92 | virtual network::steady_clock::duration sample_period() const NOEXCEPT; 93 | virtual network::wall_clock::duration currency_window() const NOEXCEPT; 94 | virtual network::thread_priority priority_() const NOEXCEPT; 95 | }; 96 | 97 | } // namespace node 98 | } // namespace libbitcoin 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /include/bitcoin/node/version.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014-2025 libbitcoin-node developers (see COPYING). 3 | // 4 | // GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | #ifndef LIBBITCOIN_NODE_VERSION_HPP 8 | #define LIBBITCOIN_NODE_VERSION_HPP 9 | 10 | /** 11 | * The semantic version of this repository as: [major].[minor].[patch] 12 | * For interpretation of the versioning scheme see: http://semver.org 13 | */ 14 | 15 | #define LIBBITCOIN_NODE_VERSION "4.0.0" 16 | #define LIBBITCOIN_NODE_MAJOR_VERSION 4 17 | #define LIBBITCOIN_NODE_MINOR_VERSION 0 18 | #define LIBBITCOIN_NODE_PATCH_VERSION 0 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libbitcoin-node-test_runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ############################################################################### 3 | # Copyright (c) 2014-2025 libbitcoin-node developers (see COPYING). 4 | # 5 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 6 | # 7 | ############################################################################### 8 | 9 | # Define tests and options. 10 | #============================================================================== 11 | BOOST_UNIT_TEST_OPTIONS=\ 12 | "--run_test=* "\ 13 | "--log_level=warning "\ 14 | "--show_progress=no "\ 15 | "--detect_memory_leak=0 "\ 16 | "--report_level=no "\ 17 | "--build_info=yes" 18 | 19 | 20 | # Run tests. 21 | #============================================================================== 22 | # ALlow CI to send errors to standard output 23 | if [[ $CI == true ]]; then 24 | ./test/libbitcoin-node-test ${BOOST_UNIT_TEST_OPTIONS} 25 | else 26 | ./test/libbitcoin-node-test ${BOOST_UNIT_TEST_OPTIONS} > test.log 27 | fi 28 | -------------------------------------------------------------------------------- /libbitcoin-node.pc.in: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2014-2025 libbitcoin-node developers (see COPYING). 3 | # 4 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | # 6 | ############################################################################### 7 | 8 | # Substitutions 9 | #============================================================================== 10 | prefix=@prefix@ 11 | exec_prefix=@exec_prefix@ 12 | libdir=@libdir@ 13 | includedir=@includedir@ 14 | 15 | 16 | # Metadata 17 | #============================================================================== 18 | Name: libbitcoin-node 19 | Description: Bitcoin Full Node 20 | URL: https://github.com/libbitcoin/libbitcoin-node 21 | Version: @PACKAGE_VERSION@ 22 | 23 | 24 | # Variables 25 | #============================================================================== 26 | # Dependencies that publish package configuration. 27 | #------------------------------------------------------------------------------ 28 | Requires: libbitcoin-database >= 4.0.0 libbitcoin-network >= 4.0.0 29 | 30 | # Include directory and any other required compiler flags. 31 | #------------------------------------------------------------------------------ 32 | Cflags: -I${includedir} 33 | 34 | # Lib directory, lib and any required that do not publish pkg-config. 35 | #------------------------------------------------------------------------------ 36 | Libs: -L${libdir} -lbitcoin-node 37 | 38 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | /libtool.m4 2 | /lt*.m4 3 | -------------------------------------------------------------------------------- /m4/ax_check_compile_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the current language's compiler 12 | # or gives an error. (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the current language's default 18 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with 19 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 20 | # force the compiler to issue an error when a bad flag is given. 21 | # 22 | # INPUT gives an alternative input source to AC_COMPILE_IFELSE. 23 | # 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 | # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2008 Guido U. Draheim 30 | # Copyright (c) 2011 Maarten Bosmans 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | 37 | #serial 6 38 | 39 | AC_DEFUN([AX_CHECK_COMPILE_FLAG], 40 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 41 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 42 | AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 43 | ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 44 | _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 45 | AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 46 | [AS_VAR_SET(CACHEVAR,[yes])], 47 | [AS_VAR_SET(CACHEVAR,[no])]) 48 | _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 49 | AS_VAR_IF(CACHEVAR,yes, 50 | [m4_default([$2], :)], 51 | [m4_default([$3], :)]) 52 | AS_VAR_POPDEF([CACHEVAR])dnl 53 | ])dnl AX_CHECK_COMPILE_FLAGS 54 | -------------------------------------------------------------------------------- /m4/ax_check_link_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the linker or gives an error. 12 | # (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the linker's default flags 18 | # when the check is done. The check is thus made with the flags: "LDFLAGS 19 | # EXTRA-FLAGS FLAG". This can for example be used to force the linker to 20 | # issue an error when a bad flag is given. 21 | # 22 | # INPUT gives an alternative input source to AC_LINK_IFELSE. 23 | # 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 | # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2008 Guido U. Draheim 30 | # Copyright (c) 2011 Maarten Bosmans 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | 37 | #serial 6 38 | 39 | AC_DEFUN([AX_CHECK_LINK_FLAG], 40 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 41 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl 42 | AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ 43 | ax_check_save_flags=$LDFLAGS 44 | LDFLAGS="$LDFLAGS $4 $1" 45 | AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 46 | [AS_VAR_SET(CACHEVAR,[yes])], 47 | [AS_VAR_SET(CACHEVAR,[no])]) 48 | LDFLAGS=$ax_check_save_flags]) 49 | AS_VAR_IF(CACHEVAR,yes, 50 | [m4_default([$2], :)], 51 | [m4_default([$3], :)]) 52 | AS_VAR_POPDEF([CACHEVAR])dnl 53 | ])dnl AX_CHECK_LINK_FLAGS 54 | -------------------------------------------------------------------------------- /m4/ax_check_preproc_flag.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_check_preproc_flag.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_PREPROC_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check whether the given FLAG works with the current language's 12 | # preprocessor or gives an error. (Warnings, however, are ignored) 13 | # 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 | # success/failure. 16 | # 17 | # If EXTRA-FLAGS is defined, it is added to the preprocessor's default 18 | # flags when the check is done. The check is thus made with the flags: 19 | # "CPPFLAGS EXTRA-FLAGS FLAG". This can for example be used to force the 20 | # preprocessor to issue an error when a bad flag is given. 21 | # 22 | # INPUT gives an alternative input source to AC_PREPROC_IFELSE. 23 | # 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 | # macro in sync with AX_CHECK_{COMPILE,LINK}_FLAG. 26 | # 27 | # LICENSE 28 | # 29 | # Copyright (c) 2008 Guido U. Draheim 30 | # Copyright (c) 2011 Maarten Bosmans 31 | # 32 | # Copying and distribution of this file, with or without modification, are 33 | # permitted in any medium without royalty provided the copyright notice 34 | # and this notice are preserved. This file is offered as-is, without any 35 | # warranty. 36 | 37 | #serial 6 38 | 39 | AC_DEFUN([AX_CHECK_PREPROC_FLAG], 40 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 41 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]cppflags_$4_$1])dnl 42 | AC_CACHE_CHECK([whether _AC_LANG preprocessor accepts $1], CACHEVAR, [ 43 | ax_check_save_flags=$CPPFLAGS 44 | CPPFLAGS="$CPPFLAGS $4 $1" 45 | AC_PREPROC_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 46 | [AS_VAR_SET(CACHEVAR,[yes])], 47 | [AS_VAR_SET(CACHEVAR,[no])]) 48 | CPPFLAGS=$ax_check_save_flags]) 49 | AS_VAR_IF(CACHEVAR,yes, 50 | [m4_default([$2], :)], 51 | [m4_default([$3], :)]) 52 | AS_VAR_POPDEF([CACHEVAR])dnl 53 | ])dnl AX_CHECK_PREPROC_FLAGS 54 | -------------------------------------------------------------------------------- /src/block_memory.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace libbitcoin { 25 | namespace node { 26 | 27 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 28 | 29 | block_memory::block_memory(size_t multiple, size_t threads) NOEXCEPT 30 | { 31 | if (is_nonzero(multiple)) 32 | { 33 | arenas_.reserve(threads); 34 | for (auto index = zero; index < threads; ++index) 35 | arenas_.emplace_back(multiple); 36 | } 37 | } 38 | 39 | arena* block_memory::get_arena() NOEXCEPT 40 | { 41 | thread_local auto thread = count_.fetch_add(one, std::memory_order_relaxed); 42 | return thread < arenas_.size() ? &arenas_.at(thread) : default_arena::get(); 43 | } 44 | 45 | BC_POP_WARNING() 46 | 47 | } // namespace node 48 | } // namespace libbitcoin 49 | -------------------------------------------------------------------------------- /src/chasers/chaser_template.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | #define CLASS chaser_template 30 | 31 | using namespace system; 32 | using namespace std::placeholders; 33 | 34 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 35 | 36 | chaser_template::chaser_template(full_node& node) NOEXCEPT 37 | : chaser(node) 38 | { 39 | } 40 | 41 | // start 42 | // ---------------------------------------------------------------------------- 43 | 44 | // TODO: initialize template state. 45 | code chaser_template::start() NOEXCEPT 46 | { 47 | SUBSCRIBE_EVENTS(handle_event, _1, _2, _3); 48 | return error::success; 49 | } 50 | 51 | // event handlers 52 | // ---------------------------------------------------------------------------- 53 | 54 | bool chaser_template::handle_event(const code&, chase event_, 55 | event_value value) NOEXCEPT 56 | { 57 | if (closed()) 58 | return false; 59 | 60 | // Stop generating query during suspension. 61 | if (suspended()) 62 | return true; 63 | 64 | // TODO: also handle confirmed/unconfirmed. 65 | switch (event_) 66 | { 67 | case chase::transaction: 68 | { 69 | BC_ASSERT(std::holds_alternative(value)); 70 | POST(do_transaction, std::get(value)); 71 | break; 72 | } 73 | case chase::stop: 74 | { 75 | return false; 76 | } 77 | default: 78 | { 79 | break; 80 | } 81 | } 82 | 83 | return true; 84 | } 85 | 86 | // TODO: handle transaction graph change (may issue 'candidate'). 87 | void chaser_template::do_transaction(transaction_t) NOEXCEPT 88 | { 89 | BC_ASSERT(stranded()); 90 | } 91 | 92 | BC_POP_WARNING() 93 | 94 | } // namespace node 95 | } // namespace libbitcoin 96 | -------------------------------------------------------------------------------- /src/chasers/chaser_transaction.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace node { 28 | 29 | #define CLASS chaser_transaction 30 | 31 | using namespace system::chain; 32 | using namespace std::placeholders; 33 | 34 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 35 | 36 | chaser_transaction::chaser_transaction(full_node& node) NOEXCEPT 37 | : chaser(node) 38 | { 39 | } 40 | 41 | // start 42 | // ---------------------------------------------------------------------------- 43 | 44 | // TODO: initialize tx graph from store, log and stop on error. 45 | code chaser_transaction::start() NOEXCEPT 46 | { 47 | SUBSCRIBE_EVENTS(handle_event, _1, _2, _3); 48 | return error::success; 49 | } 50 | 51 | // event handlers 52 | // ---------------------------------------------------------------------------- 53 | 54 | bool chaser_transaction::handle_event(const code&, chase event_, 55 | event_value) NOEXCEPT 56 | { 57 | if (closed()) 58 | return false; 59 | 60 | // TODO: allow required messages. 61 | ////// Stop generating query during suspension. 62 | ////if (suspended()) 63 | //// return true; 64 | 65 | switch (event_) 66 | { 67 | case chase::stop: 68 | { 69 | return false; 70 | } 71 | default: 72 | { 73 | break; 74 | } 75 | } 76 | 77 | return true; 78 | } 79 | 80 | // TODO: handle the new confirmed blocks (may issue 'transaction'). 81 | void chaser_transaction::do_confirmed(header_t) NOEXCEPT 82 | { 83 | BC_ASSERT(stranded()); 84 | 85 | notify(error::success, chase::transaction, transaction_t{}); 86 | } 87 | 88 | // methods 89 | // ---------------------------------------------------------------------------- 90 | 91 | void chaser_transaction::store(const transaction::cptr&) NOEXCEPT 92 | { 93 | // Push new checked tx into store and update DAG. Issue transaction event 94 | // so that candidate may construct a new template. 95 | } 96 | 97 | // private 98 | void chaser_transaction::do_store(const transaction::cptr&) NOEXCEPT 99 | { 100 | BC_ASSERT(stranded()); 101 | 102 | // TODO: validate and store transaction. 103 | } 104 | 105 | BC_POP_WARNING() 106 | 107 | } // namespace node 108 | } // namespace libbitcoin 109 | -------------------------------------------------------------------------------- /src/configuration.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | 23 | namespace libbitcoin { 24 | namespace node { 25 | 26 | using namespace bc::system; 27 | 28 | // Construct with defaults derived from given context. 29 | configuration::configuration(system::chain::selection context) NOEXCEPT 30 | : log(context), 31 | node(context), 32 | network(context), 33 | database(context), 34 | bitcoin(context) 35 | { 36 | } 37 | 38 | } // namespace node 39 | } // namespace libbitcoin 40 | -------------------------------------------------------------------------------- /src/error.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | 23 | namespace libbitcoin { 24 | namespace node { 25 | namespace error { 26 | 27 | DEFINE_ERROR_T_MESSAGE_MAP(error) 28 | { 29 | // general 30 | { success, "success" }, 31 | 32 | // database 33 | { store_uninitialized, "store not initialized" }, 34 | { store_reload, "store reload" }, 35 | { store_snapshot, "store snapshot" }, 36 | 37 | // network 38 | { slow_channel, "slow channel" }, 39 | { stalled_channel, "stalled channel" }, 40 | { exhausted_channel, "exhausted channel" }, 41 | { sacrificed_channel, "sacrificed channel" }, 42 | { suspended_channel, "sacrificed channel" }, 43 | { suspended_service, "sacrificed service" }, 44 | 45 | // blockchain 46 | { orphan_block, "orphan block" }, 47 | { orphan_header, "orphan header" }, 48 | { duplicate_block, "duplicate block" }, 49 | { duplicate_header, "duplicate header" }, 50 | 51 | /// faults 52 | { protocol1, "protocol1" }, 53 | { protocol2, "protocol2" }, 54 | { header1, "header1" }, 55 | { organize1, "organize1" }, 56 | { organize2, "organize2" }, 57 | { organize3, "organize3" }, 58 | { organize4, "organize4" }, 59 | { organize5, "organize5" }, 60 | { organize6, "organize6" }, 61 | { organize7, "organize7" }, 62 | { organize8, "organize8" }, 63 | { organize9, "organize9" }, 64 | { organize10, "organize10" }, 65 | { organize11, "organize11" }, 66 | { organize12, "organize12" }, 67 | { organize13, "organize13" }, 68 | { organize14, "organize14" }, 69 | { organize15, "organize15" }, 70 | { validate1, "validate1" }, 71 | { validate2, "validate2" }, 72 | { validate3, "validate3" }, 73 | { validate4, "validate4" }, 74 | { validate5, "validate5" }, 75 | { validate6, "validate6" }, 76 | { validate7, "validate7" }, 77 | { validate8, "validate8" }, 78 | { confirm1, "confirm1" }, 79 | { confirm2, "confirm2" }, 80 | { confirm3, "confirm3" }, 81 | { confirm4, "confirm4" }, 82 | { confirm5, "confirm5" }, 83 | { confirm6, "confirm6" }, 84 | { confirm7, "confirm7" }, 85 | { confirm8, "confirm8" }, 86 | { confirm9, "confirm9" }, 87 | { confirm10, "confirm10" }, 88 | { confirm11, "confirm11" }, 89 | { confirm12, "confirm12" }, 90 | { confirm13, "confirm13" } 91 | }; 92 | 93 | DEFINE_ERROR_T_CATEGORY(error, "node", "node code") 94 | 95 | } // namespace error 96 | } // namespace node 97 | } // namespace libbitcoin 98 | -------------------------------------------------------------------------------- /src/protocols/protocol_block_out.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | #define CLASS protocol_block_out 29 | 30 | using namespace system; 31 | using namespace network; 32 | using namespace network::messages; 33 | using namespace std::placeholders; 34 | 35 | // Start. 36 | // ---------------------------------------------------------------------------- 37 | 38 | void protocol_block_out::start() NOEXCEPT 39 | { 40 | BC_ASSERT(stranded()); 41 | 42 | if (started()) 43 | return; 44 | 45 | protocol::start(); 46 | } 47 | 48 | // Outbound. 49 | // ---------------------------------------------------------------------------- 50 | 51 | } // namespace node 52 | } // namespace libbitcoin 53 | -------------------------------------------------------------------------------- /src/protocols/protocol_header_in_70012.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace libbitcoin { 25 | namespace node { 26 | 27 | #define CLASS protocol_header_in_70012 28 | 29 | using namespace network; 30 | using namespace network::messages; 31 | using namespace std::placeholders; 32 | 33 | void protocol_header_in_70012::complete() NOEXCEPT 34 | { 35 | BC_ASSERT(stranded()); 36 | protocol_header_in_31800::complete(); 37 | 38 | if (!sent_) 39 | { 40 | SEND(send_headers{}, handle_send, _1); 41 | LOGP("Requested header announcements from [" << authority() << "]."); 42 | sent_ = true; 43 | } 44 | } 45 | 46 | } // namespace node 47 | } // namespace libbitcoin 48 | -------------------------------------------------------------------------------- /src/protocols/protocol_header_out_31800.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | #define CLASS protocol_header_out_31800 29 | 30 | using namespace system; 31 | using namespace network; 32 | using namespace network::messages; 33 | using namespace std::placeholders; 34 | 35 | // Shared pointers required for lifetime in handler parameters. 36 | BC_PUSH_WARNING(SMART_PTR_NOT_NEEDED) 37 | BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR) 38 | 39 | // Start. 40 | // ---------------------------------------------------------------------------- 41 | 42 | void protocol_header_out_31800::start() NOEXCEPT 43 | { 44 | BC_ASSERT(stranded()); 45 | 46 | if (started()) 47 | return; 48 | 49 | SUBSCRIBE_CHANNEL(headers, handle_receive_get_headers, _1, _2); 50 | protocol::start(); 51 | } 52 | 53 | // Outbound (get_headers). 54 | // ---------------------------------------------------------------------------- 55 | 56 | bool protocol_header_out_31800::handle_receive_get_headers(const code& ec, 57 | const get_headers::cptr& message) NOEXCEPT 58 | { 59 | BC_ASSERT(stranded()); 60 | 61 | if (stopped(ec)) 62 | return false; 63 | 64 | LOGP("Get headers above " << encode_hash(message->start_hash()) 65 | << " from [" << authority() << "]."); 66 | 67 | SEND(create_headers(*message), handle_send, _1); 68 | return true; 69 | } 70 | 71 | // utilities 72 | // ---------------------------------------------------------------------------- 73 | 74 | network::messages::headers protocol_header_out_31800::create_headers( 75 | const get_headers& locator) const NOEXCEPT 76 | { 77 | // Empty response implies complete (success). 78 | if (!is_current(true)) 79 | return {}; 80 | 81 | return 82 | { 83 | archive().get_headers(locator.start_hashes, locator.stop_hash, 84 | max_get_headers) 85 | }; 86 | } 87 | 88 | BC_POP_WARNING() 89 | BC_POP_WARNING() 90 | 91 | } // namespace node 92 | } // namespace libbitcoin 93 | -------------------------------------------------------------------------------- /src/protocols/protocol_header_out_70012.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | #define CLASS protocol_header_out_70012 29 | 30 | // TODO: switch to header-based announcements when "sendheaders" is received. 31 | 32 | } // namespace node 33 | } // namespace libbitcoin 34 | -------------------------------------------------------------------------------- /src/protocols/protocol_observer.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace libbitcoin { 25 | namespace node { 26 | 27 | #define CLASS protocol_observer 28 | 29 | using namespace std::placeholders; 30 | 31 | void protocol_observer::start() NOEXCEPT 32 | { 33 | BC_ASSERT(stranded()); 34 | 35 | if (started()) 36 | return; 37 | 38 | // Events subscription is asynchronous, events may be missed. 39 | subscribe_events(BIND(handle_event, _1, _2, _3), 40 | BIND(handle_complete, _1, _2)); 41 | 42 | protocol::start(); 43 | } 44 | 45 | // protected 46 | void protocol_observer::handle_complete(const code& ec, object_key) NOEXCEPT 47 | { 48 | POST(do_handle_complete, ec); 49 | } 50 | 51 | // private 52 | void protocol_observer::do_handle_complete(const code& ec) NOEXCEPT 53 | { 54 | BC_ASSERT(stranded()); 55 | 56 | if (stopped(ec)) 57 | unsubscribe_events(); 58 | } 59 | 60 | // If this is invoked before do_handle_complete then it will unsubscribe. 61 | void protocol_observer::stopping(const code& ec) NOEXCEPT 62 | { 63 | BC_ASSERT(stranded()); 64 | unsubscribe_events(); 65 | protocol::stopping(ec); 66 | } 67 | 68 | bool protocol_observer::handle_event(const code&, chase event_, 69 | event_value) NOEXCEPT 70 | { 71 | // Do not pass ec to stopped as it is not a call status. 72 | if (stopped()) 73 | return false; 74 | 75 | switch (event_) 76 | { 77 | case chase::suspend: 78 | { 79 | stop(error::suspended_channel); 80 | break; 81 | } 82 | case chase::stop: 83 | { 84 | return false; 85 | } 86 | default: 87 | { 88 | break; 89 | } 90 | } 91 | 92 | return true; 93 | } 94 | 95 | } // namespace node 96 | } // namespace libbitcoin 97 | -------------------------------------------------------------------------------- /src/protocols/protocol_transaction_in.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | #define CLASS protocol_transaction_in 29 | 30 | using namespace system; 31 | using namespace network; 32 | using namespace network::messages; 33 | using namespace std::placeholders; 34 | 35 | // Start. 36 | // ---------------------------------------------------------------------------- 37 | 38 | void protocol_transaction_in::start() NOEXCEPT 39 | { 40 | BC_ASSERT(stranded()); 41 | 42 | if (started()) 43 | return; 44 | 45 | protocol::start(); 46 | } 47 | 48 | // Inbound. 49 | // ---------------------------------------------------------------------------- 50 | 51 | } // namespace node 52 | } // namespace libbitcoin 53 | -------------------------------------------------------------------------------- /src/protocols/protocol_transaction_out.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | namespace node { 27 | 28 | #define CLASS protocol_transaction_out 29 | 30 | using namespace system; 31 | using namespace network; 32 | using namespace network::messages; 33 | using namespace std::placeholders; 34 | 35 | // Start. 36 | // ---------------------------------------------------------------------------- 37 | 38 | void protocol_transaction_out::start() NOEXCEPT 39 | { 40 | BC_ASSERT(stranded()); 41 | 42 | if (started()) 43 | return; 44 | 45 | protocol::start(); 46 | } 47 | 48 | // Outbound. 49 | // ---------------------------------------------------------------------------- 50 | 51 | } // namespace node 52 | } // namespace libbitcoin 53 | -------------------------------------------------------------------------------- /src/sessions/session_inbound.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | namespace libbitcoin { 22 | namespace node { 23 | 24 | } // namespace node 25 | } // namespace libbitcoin 26 | -------------------------------------------------------------------------------- /src/sessions/session_manual.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include 20 | 21 | namespace libbitcoin { 22 | namespace node { 23 | 24 | } // namespace node 25 | } // namespace libbitcoin 26 | -------------------------------------------------------------------------------- /test/chasers/chaser.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/chasers/chaser_block.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_blocks_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_blocks_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/chasers/chaser_check.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_check_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_check_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/chasers/chaser_confirm.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_confirm_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_confirm_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/chasers/chaser_header.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_header_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_header_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/chasers/chaser_template.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_template_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_template_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/chasers/chaser_transaction.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_transaction_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_transaction_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/chasers/chaser_validate.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(chaser_validate_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(chaser_validate_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/configuration.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "test.hpp" 20 | 21 | using namespace bc::system; 22 | using namespace bc::network; 23 | 24 | BOOST_AUTO_TEST_SUITE(configuration_tests) 25 | 26 | BOOST_AUTO_TEST_CASE(configuration__construct1__none_context__expected) 27 | { 28 | const node::configuration instance(chain::selection::none); 29 | 30 | BOOST_REQUIRE(instance.file.empty()); 31 | BOOST_REQUIRE(!instance.help); 32 | BOOST_REQUIRE(!instance.hardware); 33 | BOOST_REQUIRE(!instance.settings); 34 | BOOST_REQUIRE(!instance.version); 35 | BOOST_REQUIRE(!instance.newstore); 36 | BOOST_REQUIRE(!instance.backup); 37 | BOOST_REQUIRE(!instance.restore); 38 | BOOST_REQUIRE(!instance.flags); 39 | BOOST_REQUIRE(!instance.information); 40 | BOOST_REQUIRE(!instance.slabs); 41 | BOOST_REQUIRE(!instance.buckets); 42 | BOOST_REQUIRE(!instance.collisions); 43 | BOOST_REQUIRE(!instance.test); 44 | BOOST_REQUIRE(!instance.write); 45 | 46 | // Just a sample of settings. 47 | BOOST_REQUIRE(instance.node.headers_first); 48 | BOOST_REQUIRE_EQUAL(instance.network.threads, 1_u32); 49 | BOOST_REQUIRE_EQUAL(instance.bitcoin.first_version, 1_u32); 50 | BOOST_REQUIRE_EQUAL(instance.log.application, levels::application_defined); 51 | } 52 | 53 | BOOST_AUTO_TEST_SUITE_END() 54 | -------------------------------------------------------------------------------- /test/full_node.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(full_node_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(full_node_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #define BOOST_TEST_MODULE libbitcoin_node_test 20 | #include 21 | -------------------------------------------------------------------------------- /test/node.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(node_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(node_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/protocols/protocol.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(protocol_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(protocol_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/sessions/session.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "../test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(session_tests) 22 | 23 | BOOST_AUTO_TEST_CASE(session_test) 24 | { 25 | BOOST_REQUIRE(true); 26 | } 27 | 28 | BOOST_AUTO_TEST_SUITE_END() 29 | -------------------------------------------------------------------------------- /test/settings.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "test.hpp" 20 | 21 | BOOST_AUTO_TEST_SUITE(settings_tests) 22 | 23 | using namespace bc::network; 24 | 25 | // [log] 26 | 27 | BOOST_AUTO_TEST_CASE(settings__log__default_context__expected) 28 | { 29 | const log::settings log{}; 30 | BOOST_REQUIRE_EQUAL(log.application, levels::application_defined); 31 | BOOST_REQUIRE_EQUAL(log.news, levels::news_defined); 32 | BOOST_REQUIRE_EQUAL(log.session, levels::session_defined); 33 | BOOST_REQUIRE_EQUAL(log.protocol, false /*levels::protocol_defined*/); 34 | BOOST_REQUIRE_EQUAL(log.proxy, false /*levels::proxy_defined*/); 35 | BOOST_REQUIRE_EQUAL(log.remote, levels::remote_defined); 36 | BOOST_REQUIRE_EQUAL(log.fault, levels::fault_defined); 37 | BOOST_REQUIRE_EQUAL(log.quitting, false /*levels::quitting_defined*/); 38 | BOOST_REQUIRE_EQUAL(log.objects, false /*levels::objects_defined*/); 39 | BOOST_REQUIRE_EQUAL(log.verbose, false /*levels::verbose_defined*/); 40 | BOOST_REQUIRE_EQUAL(log.maximum_size, 1'000'000_u32); 41 | BOOST_REQUIRE_EQUAL(log.path, ""); 42 | BOOST_REQUIRE_EQUAL(log.log_file1(), "bn_end.log"); 43 | BOOST_REQUIRE_EQUAL(log.log_file2(), "bn_begin.log"); 44 | BOOST_REQUIRE_EQUAL(log.events_file(), "events.log"); 45 | #if defined(HAVE_MSC) 46 | BOOST_REQUIRE_EQUAL(log.symbols, ""); 47 | #endif 48 | } 49 | 50 | // [node] 51 | 52 | BOOST_AUTO_TEST_CASE(settings__node__default_context__expected) 53 | { 54 | using namespace network; 55 | 56 | const node::settings node{}; 57 | BOOST_REQUIRE_EQUAL(node.priority, true); 58 | BOOST_REQUIRE_EQUAL(node.headers_first, true); 59 | BOOST_REQUIRE_EQUAL(node.allowed_deviation, 1.5); 60 | BOOST_REQUIRE_EQUAL(node.maximum_height, 0_u32); 61 | BOOST_REQUIRE_EQUAL(node.allocation_multiple, 20_u16); 62 | BOOST_REQUIRE_EQUAL(node.snapshot_bytes, 200'000'000'000_u64); 63 | BOOST_REQUIRE_EQUAL(node.snapshot_valid, 250'000_u32); 64 | BOOST_REQUIRE_EQUAL(node.snapshot_confirm, 500'000_u32); 65 | BOOST_REQUIRE_EQUAL(node.maximum_height_(), max_size_t); 66 | BOOST_REQUIRE_EQUAL(node.maximum_concurrency, 50000_u32); 67 | BOOST_REQUIRE_EQUAL(node.maximum_concurrency_(), 50000_size); 68 | BOOST_REQUIRE_EQUAL(node.sample_period_seconds, 10_u16); 69 | BOOST_REQUIRE_EQUAL(node.currency_window_minutes, 60_u32); 70 | BOOST_REQUIRE_EQUAL(node.threads, 1_u32); 71 | 72 | BOOST_REQUIRE_EQUAL(node.threads_(), one); 73 | BOOST_REQUIRE_EQUAL(node.maximum_height_(), max_size_t); 74 | BOOST_REQUIRE_EQUAL(node.maximum_concurrency_(), 50'000_size); 75 | BOOST_REQUIRE(node.sample_period() == steady_clock::duration(seconds(10))); 76 | BOOST_REQUIRE(node.currency_window() == steady_clock::duration(minutes(60))); 77 | BOOST_REQUIRE(node.priority_() == network::thread_priority::high); 78 | } 79 | 80 | BOOST_AUTO_TEST_SUITE_END() 81 | -------------------------------------------------------------------------------- /test/test.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #include "test.hpp" 20 | #include 21 | 22 | namespace std { 23 | 24 | std::ostream& operator<<(std::ostream& stream, 25 | const system::data_slice& slice) NOEXCEPT 26 | { 27 | // Avoid serialize() here for its own test benefit. 28 | // stream << serialize(slice); 29 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 30 | stream << encode_base16(slice); 31 | BC_POP_WARNING() 32 | return stream; 33 | } 34 | 35 | } // namespace std 36 | 37 | namespace test { 38 | 39 | const std::string directory = "tests"; 40 | 41 | bool clear(const std::filesystem::path& directory) NOEXCEPT 42 | { 43 | // remove_all returns count removed, and error code if fails. 44 | // create_directories returns true if path exists or created. 45 | // used for setup, with no expectations of file/directory existence. 46 | const auto path = system::to_extended_path(directory); 47 | code ec; 48 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 49 | std::filesystem::remove_all(path, ec); 50 | return !ec && std::filesystem::create_directories(path, ec); 51 | BC_POP_WARNING() 52 | } 53 | 54 | bool folder(const std::filesystem::path& directory) NOEXCEPT 55 | { 56 | const auto path = system::to_extended_path(directory); 57 | code ec; 58 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 59 | return !ec && std::filesystem::is_directory(path, ec); 60 | BC_POP_WARNING() 61 | } 62 | 63 | bool create(const std::filesystem::path& file_path) NOEXCEPT 64 | { 65 | // Creates and returns true if file existed or not (and no error). 66 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 67 | std::ofstream file(system::to_extended_path(file_path)); 68 | const auto good = file.good(); 69 | file.close(); 70 | BC_POP_WARNING() 71 | return good; 72 | } 73 | 74 | bool exists(const std::filesystem::path& file_path) NOEXCEPT 75 | { 76 | // Returns true only if file existed. 77 | BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) 78 | std::ifstream file(system::to_extended_path(file_path)); 79 | const auto good = file.good(); 80 | file.close(); 81 | BC_POP_WARNING() 82 | return good; 83 | } 84 | 85 | bool remove(const std::filesystem::path& file_path) NOEXCEPT 86 | { 87 | // Deletes and returns false if file did not exist (or error). 88 | code ec; 89 | return std::filesystem::remove(system::to_extended_path(file_path), ec); 90 | } 91 | 92 | } // namespace test --------------------------------------------------------------------------------