2025-09-30 16:48:13 +01:00
// Copyright (c) 2014-2018 Zano Project
2018-12-27 18:50:45 +03:00
// Copyright (c) 2014-2018 The Louisdor Project
2025-09-30 16:48:13 +01:00
// Copyright (c) 2012-2013 The Boolberry developers
// Copyright (c) 2017-2025 Lethean (https://lt.hn)
//
// Licensed under the European Union Public Licence (EUPL) version 1.2.
// You may obtain a copy of the licence at:
//
// https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
//
// The EUPL is a copyleft licence that is compatible with the MIT/X11
// licence used by the original projects; the MIT terms are therefore
// considered “grandfathered” under the EUPL for this code.
//
// SPDX‑ License‑ Identifier: EUPL-1.2
//
2018-12-27 18:50:45 +03:00
// node.cpp : Defines the entry point for the console application.
//
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
# include "ApiServer.hpp"
2018-12-27 18:50:45 +03:00
# include "include_base_utils.h"
# include "version.h"
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
# include "oatpp/core/base/Environment.hpp"
2018-12-27 18:50:45 +03:00
using namespace epee ;
# include <boost/program_options.hpp>
# include "crypto/hash.h"
# include "console_handler.h"
# include "p2p/net_node.h"
# include "currency_core/checkpoints_create.h"
# include "currency_core/currency_core.h"
# include "rpc/core_rpc_server.h"
2019-03-29 05:43:23 +03:00
# include "stratum/stratum_server.h"
2018-12-27 18:50:45 +03:00
# include "currency_protocol/currency_protocol_handler.h"
# include "daemon_commands_handler.h"
# include "common/miniupnp_helper.h"
# include "version.h"
# include "currency_core/core_tools.h"
2019-08-27 22:18:55 +03:00
# include "common/callstack_helper.h"
2020-03-12 18:07:31 +03:00
# include "common/pre_download.h"
2018-12-27 18:50:45 +03:00
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
# include <cstdlib>
2018-12-27 18:50:45 +03:00
# if defined(WIN32)
# include <crtdbg.h>
# pragma comment(lib, "ntdll") // <-- why do we need this?
# endif
2025-03-12 19:51:51 +04:00
const uint64_t min_ram_for_full_warp_mode = 32ULL * 1024ULL * 1024ULL * 1024ULL ;
const uint64_t recommended_ram_for_full_warp_mode = 64ULL * 1024ULL * 1024ULL * 1024ULL ;
2018-12-27 18:50:45 +03:00
//TODO: need refactoring here. (template classes can't be used in BOOST_CLASS_VERSION)
BOOST_CLASS_VERSION ( nodetool : : node_server < currency : : t_currency_protocol_handler < currency : : core > > , CURRENT_P2P_STORAGE_ARCHIVE_VER ) ;
2025-03-12 14:17:20 +04:00
const command_line : : arg_descriptor < uint32_t > arg_rpc_server_threads ( " rpc-server-threads " , " Specify number of RPC server threads. Default: 10 " , RPC_SERVER_DEFAULT_THREADS_NUM ) ;
2025-03-12 19:51:51 +04:00
const command_line : : arg_descriptor < bool > arg_do_warp_mode ( " do-warp-mode " , " This option pre-loads and unserialize all data into RAM and provide significant speed increase in RPC-handling, requires 32GB psychical RAM at least(64GB recommended). Might be helpful for production servers(like remote nodes or public nodes for mobile apps). " ) ;
2018-12-27 18:50:45 +03:00
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
2018-12-27 18:50:45 +03:00
namespace po = boost : : program_options ;
bool command_line_preprocessor ( const boost : : program_options : : variables_map & vm ) ;
2019-07-02 18:38:35 +03:00
template < typename p2psrv_t >
struct core_critical_error_handler_t : public currency : : i_critical_error_handler
{
core_critical_error_handler_t ( daemon_commands_handler & dch , p2psrv_t & p2psrv , bool dont_stop_on_time_error , bool dont_stop_on_low_space )
: dch ( dch )
, p2psrv ( p2psrv )
, dont_stop_on_time_error ( dont_stop_on_time_error )
, dont_stop_on_low_space ( dont_stop_on_low_space )
{ }
// interface currency::i_critical_error_handler
virtual bool on_critical_time_sync_error ( ) override
{
if ( dont_stop_on_time_error )
return false ; // ignore such errors
2024-07-17 19:29:46 +04:00
LOG_ERROR ( ENDL < < ENDL < < " Serious TIME sync problem detected, daemon will stop immediately " < < ENDL < < ENDL ) ;
2019-07-02 18:38:35 +03:00
// stop handling
2025-05-05 21:32:50 +04:00
p2psrv . send_stop_signal ( ) ;
2019-07-02 18:38:35 +03:00
return true ; // the caller must stop processing
}
// interface currency::i_critical_error_handler
virtual bool on_critical_low_free_space ( uint64_t available , uint64_t required ) override
{
if ( dont_stop_on_low_space )
return false ; // ignore such errors
LOG_ERROR ( ENDL < < ENDL < < " Free space at data directory is critically low ( " < < available / ( 1024 * 1024 ) < < " MB, while " < < required / ( 1024 * 1024 ) < < " MB is required), daemon will stop immediately " < < ENDL < < ENDL ) ;
2019-10-14 15:28:35 +03:00
/*
temporary disable daemon stop due to issue # 133
*/
return false ;
/*
2019-07-02 18:38:35 +03:00
// stop handling
dch . stop_handling ( ) ;
p2psrv . send_stop_signal ( ) ;
return true ; // the caller must stop processing
2019-10-14 15:28:35 +03:00
*/
2019-07-02 18:38:35 +03:00
}
2020-07-02 23:16:47 +03:00
virtual bool on_immediate_stop_requested ( ) override
{
LOG_PRINT_L0 ( ENDL < < ENDL < < " immediate daemon stop requested, stopping... " < < ENDL < < ENDL ) ;
dch . stop_handling ( ) ;
p2psrv . send_stop_signal ( ) ;
return true ; // the caller must stop processing
}
2019-07-02 18:38:35 +03:00
daemon_commands_handler & dch ;
p2psrv_t & p2psrv ;
bool dont_stop_on_time_error ;
bool dont_stop_on_low_space ;
} ;
2019-09-19 16:57:16 +03:00
void terminate_handler_func ( )
{
LOG_ERROR ( " \n \n TERMINATE HANDLER \n " ) ; // should print callstack
std : : fflush ( nullptr ) ; // all open output streams are flushed
std : : abort ( ) ; // default terminate handler's behavior
}
2018-12-27 18:50:45 +03:00
int main ( int argc , char * argv [ ] )
{
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
try
{
TRY_ENTRY ( ) ;
2018-12-27 18:50:45 +03:00
string_tools : : set_module_name_and_folder ( argv [ 0 ] ) ;
# ifdef WIN32
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ) ;
//_CrtSetAllocHook(alloc_hook);
# endif
2019-10-11 19:52:04 +02:00
log_space : : get_set_log_detalisation_level ( true , LOG_LEVEL_0 ) ;
2018-12-27 18:50:45 +03:00
log_space : : log_singletone : : add_logger ( LOGGER_CONSOLE , NULL , NULL ) ;
2022-10-14 19:08:27 +02:00
log_space : : log_singletone : : enable_channels ( " core,currency_protocol,tx_pool,wallet " , false ) ;
2018-12-27 18:50:45 +03:00
tools : : signal_handler : : install_fatal ( [ ] ( int sig_number , void * address ) {
LOG_ERROR ( " \n \n FATAL ERROR \n sig: " < < sig_number < < " , address: " < < address ) ;
std : : fflush ( nullptr ) ; // all open output streams are flushed
} ) ;
2019-08-29 04:36:35 +03:00
// setup custom callstack retrieving function
2019-08-27 22:18:55 +03:00
epee : : misc_utils : : get_callstack ( tools : : get_callstack ) ;
2019-09-19 17:07:12 +03:00
// setup custom terminate functions
2019-09-19 16:57:16 +03:00
std : : set_terminate ( & terminate_handler_func ) ;
2018-12-27 18:50:45 +03:00
po : : options_description desc_cmd_only ( " Command line options " ) ;
po : : options_description desc_cmd_sett ( " Command line options and settings options " , 130 , 83 ) ;
command_line : : add_arg ( desc_cmd_only , command_line : : arg_help ) ;
command_line : : add_arg ( desc_cmd_only , command_line : : arg_version ) ;
command_line : : add_arg ( desc_cmd_only , command_line : : arg_os_version ) ;
// tools::get_default_data_dir() can't be called during static initialization
2022-04-21 20:57:46 +02:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_data_dir , tools : : get_default_data_dir ( ) ) ;
2020-07-02 23:16:47 +03:00
command_line : : add_arg ( desc_cmd_only , command_line : : arg_stop_after_height ) ;
2018-12-27 18:50:45 +03:00
command_line : : add_arg ( desc_cmd_only , command_line : : arg_config_file ) ;
2019-05-19 01:24:41 +00:00
command_line : : add_arg ( desc_cmd_only , command_line : : arg_disable_upnp ) ;
2018-12-27 18:50:45 +03:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_log_dir ) ;
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_log_level ) ;
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_console ) ;
2022-04-21 20:57:46 +02:00
command_line : : add_arg ( desc_cmd_only , command_line : : arg_show_details ) ;
2024-04-09 22:52:41 +02:00
command_line : : add_arg ( desc_cmd_only , command_line : : arg_generate_rpc_autodoc ) ;
2019-06-07 15:15:14 +03:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_disable_stop_if_time_out_of_sync ) ;
2019-07-02 18:38:35 +03:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_disable_stop_on_low_free_space ) ;
2019-08-28 22:52:07 +02:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_enable_offers_service ) ;
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
2020-03-12 18:07:31 +03:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_no_predownload ) ;
2020-03-18 15:14:10 +03:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_force_predownload ) ;
2024-02-18 21:05:22 +04:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_process_predownload_from_path ) ;
2020-03-12 18:07:31 +03:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_validate_predownload ) ;
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_predownload_link ) ;
2022-01-04 05:14:11 +00:00
command_line : : add_arg ( desc_cmd_sett , command_line : : arg_disable_ntp ) ;
2025-03-12 19:51:51 +04:00
2025-03-12 14:17:20 +04:00
command_line : : add_arg ( desc_cmd_sett , arg_rpc_server_threads ) ;
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
command_line : : add_arg ( desc_cmd_sett , arg_do_warp_mode ) ;
2018-12-27 18:50:45 +03:00
arg_market_disable . default_value = true ;
2022-04-21 19:00:03 +02:00
arg_market_disable . use_default = true ;
2018-12-27 18:50:45 +03:00
currency : : core : : init_options ( desc_cmd_sett ) ;
currency : : core_rpc_server : : init_options ( desc_cmd_sett ) ;
2019-07-02 18:38:35 +03:00
typedef nodetool : : node_server < currency : : t_currency_protocol_handler < currency : : core > > p2psrv_t ;
p2psrv_t : : init_options ( desc_cmd_sett ) ;
2025-01-24 04:41:55 +01:00
# ifdef CPU_MINING_ENABLED
2018-12-27 18:50:45 +03:00
currency : : miner : : init_options ( desc_cmd_sett ) ;
2025-01-24 04:41:55 +01:00
# endif
2018-12-27 18:50:45 +03:00
bc_services : : bc_offers_service : : init_options ( desc_cmd_sett ) ;
2019-03-29 05:43:23 +03:00
currency : : stratum_server : : init_options ( desc_cmd_sett ) ;
2020-03-12 13:21:22 +03:00
tools : : db : : db_backend_selector : : init_options ( desc_cmd_sett ) ;
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
ApiServer : : init_options ( desc_cmd_sett ) ;
2018-12-27 18:50:45 +03:00
po : : options_description desc_options ( " Allowed options " ) ;
desc_options . add ( desc_cmd_only ) . add ( desc_cmd_sett ) ;
2025-03-12 14:17:20 +04:00
2025-04-30 03:55:13 +03:00
std : : string data_dir ;
2018-12-27 18:50:45 +03:00
po : : variables_map vm ;
2025-01-21 02:22:13 +01:00
bool exit_requested = false ;
2018-12-27 18:50:45 +03:00
bool r = command_line : : handle_error_helper ( desc_options , [ & ] ( )
{
po : : store ( po : : parse_command_line ( argc , argv , desc_options ) , vm ) ;
if ( command_line : : get_arg ( vm , command_line : : arg_help ) )
{
std : : cout < < CURRENCY_NAME < < " v " < < PROJECT_VERSION_LONG < < ENDL < < ENDL ;
std : : cout < < desc_options < < std : : endl ;
2025-01-21 02:22:13 +01:00
exit_requested = true ;
return true ;
}
else if ( command_line : : get_arg ( vm , command_line : : arg_version ) )
{
std : : cout < < CURRENCY_NAME < < " v " < < PROJECT_VERSION_LONG < < ENDL < < ENDL ;
exit_requested = true ;
return true ;
2018-12-27 18:50:45 +03:00
}
2025-04-30 03:55:13 +03:00
data_dir = command_line : : get_arg ( vm , command_line : : arg_data_dir ) ;
2018-12-27 18:50:45 +03:00
std : : string config = command_line : : get_arg ( vm , command_line : : arg_config_file ) ;
2019-09-25 17:09:38 +03:00
boost : : filesystem : : path data_dir_path ( epee : : string_encoding : : utf8_to_wstring ( data_dir ) ) ;
boost : : filesystem : : path config_path ( epee : : string_encoding : : utf8_to_wstring ( config ) ) ;
2018-12-27 18:50:45 +03:00
if ( ! config_path . has_parent_path ( ) )
{
config_path = data_dir_path / config_path ;
}
boost : : system : : error_code ec ;
if ( boost : : filesystem : : exists ( config_path , ec ) )
{
po : : store ( po : : parse_config_file < char > ( config_path . string < std : : string > ( ) . c_str ( ) , desc_cmd_sett ) , vm ) ;
}
po : : notify ( vm ) ;
return true ;
} ) ;
2025-01-21 02:22:13 +01:00
2018-12-27 18:50:45 +03:00
if ( ! r )
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
return EXIT_FAILURE ;
2018-12-27 18:50:45 +03:00
2025-01-21 02:22:13 +01:00
if ( exit_requested )
return EXIT_SUCCESS ;
2018-12-27 18:50:45 +03:00
//set up logging options
2025-04-30 03:55:13 +03:00
std : : string log_dir = data_dir ;
2018-12-27 18:50:45 +03:00
std : : string log_file_name = log_space : : log_singletone : : get_default_log_file ( ) ;
//check if there was specific option
if ( command_line : : has_arg ( vm , command_line : : arg_log_dir ) )
log_dir = command_line : : get_arg ( vm , command_line : : arg_log_dir ) ;
log_space : : log_singletone : : add_logger ( LOGGER_FILE , log_file_name . c_str ( ) , log_dir . c_str ( ) ) ;
LOG_PRINT_L0 ( CURRENCY_NAME < < " v " < < PROJECT_VERSION_LONG ) ;
if ( command_line_preprocessor ( vm ) )
{
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
return EXIT_SUCCESS ;
2018-12-27 18:50:45 +03:00
}
2025-01-21 02:22:13 +01:00
LOG_PRINT_L0 ( " Starting... " ) ;
2018-12-27 18:50:45 +03:00
2019-03-29 05:43:23 +03:00
// stratum server is enabled if any of its options present
bool stratum_enabled = currency : : stratum_server : : should_start ( vm ) ;
2025-04-30 03:55:13 +03:00
LOG_PRINT ( " Module folder: " < < argv [ 0 ] < < " , data folder: " < < data_dir , LOG_LEVEL_0 ) ;
2018-12-27 18:50:45 +03:00
//create objects and link them
bc_services : : bc_offers_service offers_service ( nullptr ) ;
2019-10-11 19:52:04 +02:00
offers_service . set_disabled ( true ) ; //disable by default
2018-12-27 18:50:45 +03:00
currency : : core ccore ( NULL ) ;
currency : : t_currency_protocol_handler < currency : : core > cprotocol ( ccore , NULL ) ;
2019-07-02 18:38:35 +03:00
p2psrv_t p2psrv ( cprotocol ) ;
2018-12-27 18:50:45 +03:00
currency : : core_rpc_server rpc_server ( ccore , p2psrv , offers_service ) ;
cprotocol . set_p2p_endpoint ( & p2psrv ) ;
ccore . set_currency_protocol ( & cprotocol ) ;
2019-06-17 23:59:45 +03:00
daemon_commands_handler dch ( p2psrv , rpc_server ) ;
2019-07-02 18:38:35 +03:00
core_critical_error_handler_t < p2psrv_t > cceh ( dch , p2psrv ,
command_line : : get_arg ( vm , command_line : : arg_disable_stop_if_time_out_of_sync ) ,
command_line : : get_arg ( vm , command_line : : arg_disable_stop_on_low_free_space ) ) ;
ccore . set_critical_error_handler ( & cceh ) ;
2019-06-07 15:15:14 +03:00
2019-08-28 22:52:07 +02:00
if ( command_line : : get_arg ( vm , command_line : : arg_enable_offers_service ) )
{
2019-10-11 19:52:04 +02:00
offers_service . set_disabled ( false ) ;
2019-08-28 22:52:07 +02:00
ccore . get_blockchain_storage ( ) . get_attachment_services_manager ( ) . add_service ( & offers_service ) ;
}
2019-10-11 19:52:04 +02:00
2019-08-28 22:52:07 +02:00
std : : shared_ptr < currency : : stratum_server > stratum_server_ptr ;
2019-03-29 05:43:23 +03:00
if ( stratum_enabled )
stratum_server_ptr = std : : make_shared < currency : : stratum_server > ( & ccore ) ;
2018-12-27 18:50:45 +03:00
2024-04-10 13:50:03 +02:00
2024-04-09 22:52:41 +02:00
if ( command_line : : has_arg ( vm , command_line : : arg_generate_rpc_autodoc ) )
2018-12-27 18:50:45 +03:00
{
2024-04-10 13:50:03 +02:00
std : : string path_to_generate = command_line : : get_arg ( vm , command_line : : arg_generate_rpc_autodoc ) ;
2025-03-31 16:14:46 +04:00
std : : string auto_doc_sufix = " <sub>Auto-doc built with: " PROJECT_VERSION_LONG " </sub> " ;
2025-03-31 15:37:21 +04:00
if ( ! generate_doc_as_md_files ( path_to_generate , rpc_server , auto_doc_sufix ) )
2024-04-10 13:50:03 +02:00
return 1 ;
2024-03-20 14:45:29 +01:00
return 0 ;
2018-12-27 18:50:45 +03:00
}
bool res = false ;
2020-03-12 13:21:22 +03:00
2020-03-12 18:07:31 +03:00
//do pre_download if needed
2020-03-18 15:14:10 +03:00
if ( ! command_line : : has_arg ( vm , command_line : : arg_no_predownload ) | | command_line : : has_arg ( vm , command_line : : arg_force_predownload ) )
2020-03-12 18:07:31 +03:00
{
2020-03-16 17:48:02 +03:00
auto is_stop_signal_sent = [ & p2psrv ] ( ) - > bool {
return static_cast < nodetool : : i_p2p_endpoint < currency : : t_currency_protocol_handler < currency : : core > : : connection_context > * > ( & p2psrv ) - > is_stop_signal_sent ( ) ;
} ;
if ( ! tools : : process_predownload ( vm , [ & ] ( uint64_t total_bytes , uint64_t received_bytes ) { return is_stop_signal_sent ( ) ; } ) )
{
return EXIT_FAILURE ;
}
if ( is_stop_signal_sent ( ) )
2020-03-12 18:07:31 +03:00
return 1 ;
}
2018-12-27 18:50:45 +03:00
//initialize objects
LOG_PRINT_L0 ( " Initializing p2p server... " ) ;
res = p2psrv . init ( vm ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize p2p server. " ) ;
LOG_PRINT_L0 ( " P2p server initialized OK on port: " < < p2psrv . get_this_peer_port ( ) ) ;
2019-10-11 19:52:04 +02:00
tools : : miniupnp_helper upnp_helper ;
2019-05-19 01:24:41 +00:00
if ( ! command_line : : get_arg ( vm , command_line : : arg_disable_upnp ) )
{
LOG_PRINT_L0 ( " Starting UPnP " ) ;
upnp_helper . start_regular_mapping ( p2psrv . get_this_peer_port ( ) , p2psrv . get_this_peer_port ( ) , 20 * 60 * 1000 ) ;
}
2018-12-27 18:50:45 +03:00
LOG_PRINT_L0 ( " Initializing currency protocol... " ) ;
res = cprotocol . init ( vm ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize currency protocol. " ) ;
LOG_PRINT_L0 ( " Currency protocol initialized OK " ) ;
LOG_PRINT_L0 ( " Initializing core rpc server... " ) ;
res = rpc_server . init ( vm ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize core rpc server. " ) ;
LOG_PRINT_GREEN ( " Core rpc server initialized OK on port: " < < rpc_server . get_binded_port ( ) , LOG_LEVEL_0 ) ;
2019-04-02 21:07:03 +02:00
//initialize core here
LOG_PRINT_L0 ( " Initializing core... " ) ;
2020-03-16 17:48:02 +03:00
res = ccore . init ( vm ) ;
2019-04-02 21:07:03 +02:00
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize core " ) ;
LOG_PRINT_L0 ( " Core initialized OK " ) ;
2019-03-29 05:43:23 +03:00
if ( stratum_enabled )
{
LOG_PRINT_L0 ( " Initializing stratum server... " ) ;
res = stratum_server_ptr - > init ( vm ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize stratum server. " ) ;
}
2019-04-02 21:07:03 +02:00
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
2018-12-27 18:50:45 +03:00
auto & bcs = ccore . get_blockchain_storage ( ) ;
if ( ! offers_service . is_disabled ( ) & & bcs . get_current_blockchain_size ( ) > 1 & & bcs . get_top_block_id ( ) ! = offers_service . get_last_seen_block_id ( ) )
{
res = resync_market ( bcs , offers_service ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize core: resync_market " ) ;
}
currency : : checkpoints checkpoints ;
res = currency : : create_checkpoints ( checkpoints ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize checkpoints " ) ;
res = ccore . set_checkpoints ( std : : move ( checkpoints ) ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize core " ) ;
2025-03-12 19:51:51 +04:00
//do full warp mode if needed
if ( command_line : : has_arg ( vm , arg_do_warp_mode ) )
{
LOG_PRINT_MAGENTA ( " Initializing full warp-mode " , LOG_LEVEL_0 ) ;
//let's check if cache size were specifically set
if ( ! command_line : : has_arg ( vm , arg_db_cache_l2 ) )
{
//overriding caching settings
uint64_t cache_size = ccore . get_blockchain_storage ( ) . get_total_transactions ( ) * 10 ;
ccore . get_blockchain_storage ( ) . set_db_l2_cache_size ( cache_size ) ;
LOG_PRINT_MAGENTA ( " [Warp]: Setting up db cache to " < < tools : : pretty_print_big_nums ( cache_size ) < < " items..... " , LOG_LEVEL_0 ) ;
}
uint64_t phisical_ram_detected = tools : : get_total_system_memory ( ) ;
if ( phisical_ram_detected < min_ram_for_full_warp_mode )
{
LOG_PRINT_RED_L0 ( " [Warp]: Detected only " < < tools : : pretty_print_big_nums ( phisical_ram_detected ) < < " B of RAM, it's not recommended to run daemon in full warm up mode under " < < tools : : pretty_print_big_nums ( min_ram_for_full_warp_mode ) < < " B, stopping... " ) ;
return 1 ;
}
else
{
if ( phisical_ram_detected < recommended_ram_for_full_warp_mode )
{
LOG_PRINT_MAGENTA ( " [Warp]: Detected only " < < tools : : pretty_print_big_nums ( phisical_ram_detected ) < < " B RAM, might be not optimal, recommended above " < < tools : : pretty_print_big_nums ( recommended_ram_for_full_warp_mode ) < < " B " , LOG_LEVEL_0 ) ;
}
else
{
LOG_PRINT_GREEN ( " [Warp]: Detected " < < tools : : pretty_print_big_nums ( phisical_ram_detected ) < < " B RAM " , LOG_LEVEL_0 ) ;
}
}
LOG_PRINT_MAGENTA ( " [Warp]: Launching warm up.... " , LOG_LEVEL_0 ) ;
ccore . get_blockchain_storage ( ) . do_full_db_warm_up ( ) ;
LOG_PRINT_MAGENTA ( " [Warp]: Warm up finished! " , LOG_LEVEL_0 ) ;
}
2025-06-07 14:10:45 +04:00
//detect if console is available
if ( isatty ( fileno ( stdin ) ) )
2018-12-27 18:50:45 +03:00
{
2025-06-07 14:10:45 +04:00
// start components
if ( ! command_line : : has_arg ( vm , command_line : : arg_console ) )
{
dch . start_handling ( ) ;
}
2018-12-27 18:50:45 +03:00
}
2025-03-12 14:17:20 +04:00
uint32_t rpc_threads_count = RPC_SERVER_DEFAULT_THREADS_NUM ;
if ( command_line : : has_arg ( vm , arg_rpc_server_threads ) )
{
rpc_threads_count = command_line : : get_arg ( vm , arg_rpc_server_threads ) ;
if ( rpc_threads_count < 2 )
{
LOG_ERROR ( " RPC server threads number number is too low: " < < rpc_threads_count < < " (why would you do that?!) " ) ;
return false ;
}
LOG_PRINT_L0 ( " RPC server threads number is overridden with " < < rpc_threads_count ) ;
if ( rpc_threads_count < RPC_SERVER_DEFAULT_THREADS_NUM )
{
LOG_PRINT_RED_L0 ( " Warning: RPC server threads number is overridden with low number: " < < rpc_threads_count < < " (why would you do that?!) " ) ;
}
}
2018-12-27 18:50:45 +03:00
LOG_PRINT_L0 ( " Starting core rpc server... " ) ;
2025-03-12 14:17:20 +04:00
res = rpc_server . run ( rpc_threads_count , false ) ;
2018-12-27 18:50:45 +03:00
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to initialize core rpc server. " ) ;
LOG_PRINT_L0 ( " Core rpc server started ok " ) ;
2019-04-02 21:07:03 +02:00
//start stratum only after core got initialized
2019-03-29 05:43:23 +03:00
if ( stratum_enabled )
{
LOG_PRINT_L0 ( " Starting stratum server... " ) ;
res = stratum_server_ptr - > run ( false ) ;
CHECK_AND_ASSERT_MES ( res , 1 , " Failed to start stratum server. " ) ;
LOG_PRINT_L0 ( " Stratum server started ok " ) ;
}
2018-12-27 18:50:45 +03:00
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
std : : unique_ptr < ApiServer > api_server ;
oatpp : : base : : Environment : : init ( ) ;
api_server = std : : make_unique < ApiServer > ( vm , & ccore , & p2psrv , & rpc_server ) ;
api_server - > start ( ) ;
// Setup signal handler to gracefully stop the main p2p loop
tools : : signal_handler : : install ( [ & p2psrv ] {
LOG_PRINT_L0 ( " SIGINT received, stopping p2p net loop... " ) ;
2018-12-27 18:50:45 +03:00
p2psrv . send_stop_signal ( ) ;
} ) ;
LOG_PRINT_L0 ( " Starting p2p net loop... " ) ;
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
p2psrv . run ( ) ; // This blocks until the stop signal is received
LOG_PRINT_L0 ( " p2p net loop stopped. Starting shutdown... " ) ;
2018-12-27 18:50:45 +03:00
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
// Shutdown sequence
LOG_PRINT_L0 ( " Stopping command handler... " ) ;
dch . stop_handling ( ) ;
LOG_PRINT_L0 ( " Stopping API server... " ) ;
api_server - > stop ( ) ;
api_server - > wait ( ) ;
LOG_PRINT_L0 ( " API server stopped " ) ;
//stop other components
2019-03-29 05:43:23 +03:00
if ( stratum_enabled )
{
LOG_PRINT_L0 ( " Stopping stratum server... " ) ;
stratum_server_ptr - > send_stop_signal ( ) ;
stratum_server_ptr - > timed_wait_server_stop ( 1000 ) ;
LOG_PRINT_L0 ( " Stratum server stopped " ) ;
}
2018-12-27 18:50:45 +03:00
LOG_PRINT_L0 ( " Stopping core rpc server... " ) ;
rpc_server . send_stop_signal ( ) ;
rpc_server . timed_wait_server_stop ( 5000 ) ;
//deinitialize components
LOG_PRINT_L0 ( " Deinitializing core... " ) ;
offers_service . set_last_seen_block_id ( ccore . get_blockchain_storage ( ) . get_top_block_id ( ) ) ;
ccore . deinit ( ) ;
LOG_PRINT_L0 ( " Deinitializing market... " ) ;
( static_cast < currency : : i_bc_service & > ( offers_service ) ) . deinit ( ) ;
2019-03-29 05:43:23 +03:00
LOG_PRINT_L0 ( " Deinitializing stratum server ... " ) ;
stratum_server_ptr . reset ( ) ;
2018-12-27 18:50:45 +03:00
LOG_PRINT_L0 ( " Deinitializing rpc server ... " ) ;
rpc_server . deinit ( ) ;
LOG_PRINT_L0 ( " Deinitializing currency_protocol... " ) ;
cprotocol . deinit ( ) ;
LOG_PRINT_L0 ( " Deinitializing p2p... " ) ;
p2psrv . deinit ( ) ;
New API Interface (#27)
This pull request introduces a comprehensive new API interface for the blockchain, leveraging OpenAPI v3 to facilitate direct consumption of chain data by GUI and web applications. This change significantly refines the project's build infrastructure, incorporating Conan for dependency management and CMake for configuration, alongside the integration of an OpenAPI Generator to produce SDKs for multiple languages.
### Highlights
* **New API Interface**: Introduced a new API interface using OpenAPI v3 to enable GUI/WEB development to consume chain data without needing custom server applications.
* **Build System Enhancements**: Significant updates to the build system, including Makefile, CMake, and Conan configurations, to streamline the build process and support new functionalities.
* **Multi-language SDK Generation**: Integrated OpenAPI Generator to automatically create SDKs for various programming languages, including Go, Angular, and PHP, simplifying client-side integration.
2025-10-19 19:12:37 +01:00
// LOG_PRINT_L0("Destroying oatpp environment...");
oatpp : : base : : Environment : : destroy ( ) ;
// LOG_PRINT_L0("oatpp environment destroyed.");
//
2019-07-02 18:38:35 +03:00
ccore . set_critical_error_handler ( nullptr ) ;
2018-12-27 18:50:45 +03:00
ccore . set_currency_protocol ( NULL ) ;
cprotocol . set_p2p_endpoint ( NULL ) ;
LOG_PRINT ( " Node stopped. " , LOG_LEVEL_0 ) ;
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
return EXIT_SUCCESS ;
2018-12-27 18:50:45 +03:00
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR)
* stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_blockchain_update_listener, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro
A temporary substition for what I hope will eventually be a full-fledged
exception-dispatcher (class-based, not macro).
* stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger,
remove_protocol_handler, and any paths involving the logger
(including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT)
The potential to throw exists within guarded_critical_region_t, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT)
The potential to throw exists within the logger, del_connection, and any
paths involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: move macros to *top* of file
so they can be used *within* this file.
* daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT)
The potential to throw exists within log_space, and any paths involving
the logger (including CATCH_ENTRY_*).
* daemon: return cstdlib proper types in main
* simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT)
CID: 210082
CID: 210086
CID: 210096
CID: 210147
CID: 210149
CID: 210150
The potential to throw exists throughout various paths in main.
* simplewallet: return cstdlib proper types in main
* simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, and any paths
involving the logger (including CATCH_ENTRY_*).
* conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT)
CID: 210038
CID: 210047
CID: 210108
CID: 210122
CID: 210157
The potential to throw exists throughout various paths in main.
* conn_tool: return cstdlib proper types in main
* miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT)
The potential to throw exists within deinit, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT)
The potential to throw exists within boost microsec_clock::localtime(),
and any paths involving the logger (including CATCH_ENTRY_*).
* db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT)
The potential to throw exists within close(), including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT)
The potential to throw exists within several paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210064
CID: 210093
CID: 210136
CID: 210139
The potential to throw exists within m_func(), including any paths
involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210072
CID: 210094
CID: 210116
CID: 210141
The potential to throw exists within m_cache.clear(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT)
The potential to throw exists within shutdown(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT)
The potential to throw exists within unlock(), including any
paths involving the logger (including CATCH_ENTRY_*).
* epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT)
The potential to throw exists within various paths, including any paths
involving the logger (including CATCH_ENTRY_*).
* epee: http_base: resolve CID 210176 (UNINIT_CTOR)
* p2p: net_node: resolve CID 210173 (UNINIT_CTOR)
* epee: net_helper: resolve CID 210138 (UNINIT_CTOR)
* p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR)
* currency_basic: resolve CID 210117 (UNINIT_CTOR)
* epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR)
CID: 210040
CID: 210090
CID: 210105
* simplewallet: resolve CID 210103 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR)
* json_archive: resolve CID 210087 (UNINIT_CTOR)
* epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR)
* miniupnp_helper: resolve CID 210037 (UNINIT_CTOR)
* crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN)
* wallet2: resolve CID 210041 (CHECKED_RETURN)
* epee: misc_log_ex: resolve CID 210127 (DEADCODE)
* epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE)
CID: 210167
CID: 210170
CID: 210180
* p2p: net_node: resolve CID 210065 (PASS_BY_VALUE)
* epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE)
* epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE)
* epee: misc_log_ex: add NESTED_*_ENTRY macros
* simplewallet: use NESTED_*_ENTRY in message_writer dtor
* stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor
* stratum_protocol_handler: use NESTED_*_ENTRY in dtor
* lmdb_db_backend: use NESTED_*_ENTRY in dtor
* epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT)
CID: 210088
CID: 210106
CID: 210164
CID: 210179
The potential to throw exists within various paths, including any
paths involving the logger (including CATCH_ENTRY_*).
* db_abstract_accessor: use NESTED_*_ENTRY in dtor
* miniupnp_helper: use NESTED_*_ENTRY in dtor
* epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor
* epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors
* epee: net_helper: use NESTED_*_ENTRY in dtor
* epee: profile_tools: use NESTED_*_ENTRY in dtors
* epee: misc_language: use NESTED_*_ENTRY in dtor
* epee: syncobj: use NESTED_*_ENTRY in dtor
* zano: license contact w/ zano.org email instead of sekreta.org email
2019-05-20 09:32:36 +00:00
CATCH_ENTRY_L0 ( __func__ , EXIT_FAILURE ) ;
}
catch ( . . . )
{
return EXIT_FAILURE ;
}
2018-12-27 18:50:45 +03:00
}
bool command_line_preprocessor ( const boost : : program_options : : variables_map & vm )
{
bool exit = false ;
if ( command_line : : get_arg ( vm , command_line : : arg_version ) )
{
std : : cout < < CURRENCY_NAME < < " v " < < PROJECT_VERSION_LONG < < ENDL ;
exit = true ;
}
if ( command_line : : get_arg ( vm , command_line : : arg_show_details ) )
{
currency : : print_currency_details ( ) ;
exit = true ;
}
if ( command_line : : get_arg ( vm , command_line : : arg_os_version ) )
{
std : : cout < < " OS: " < < tools : : get_os_version_string ( ) < < ENDL ;
exit = true ;
}
if ( exit )
{
return true ;
}
if ( command_line : : has_arg ( vm , command_line : : arg_log_level ) )
{
int new_log_level = command_line : : get_arg ( vm , command_line : : arg_log_level ) ;
if ( new_log_level < LOG_LEVEL_MIN | | new_log_level > LOG_LEVEL_MAX )
{
LOG_PRINT_L0 ( " Wrong log level value: " ) ;
}
else if ( log_space : : get_set_log_detalisation_level ( false ) ! = new_log_level )
{
log_space : : get_set_log_detalisation_level ( true , new_log_level ) ;
LOG_PRINT_L0 ( " LOG_LEVEL set to " < < new_log_level ) ;
}
}
return false ;
}