From 4f74153e566b9a83e36486e4471a4fa247fffcc3 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Sat, 2 Mar 2019 22:12:43 -0800 Subject: [PATCH] Added cn utils lib. --- src/Makefile.am | 19 +++++++++++++++++++ src/Makefile.bench.include | 1 + src/Makefile.qt.include | 4 ++-- src/Makefile.qttest.include | 2 +- src/Makefile.test.include | 3 ++- .../portable_storage_val_converters.h | 2 +- src/cn_utils/crypto/chacha8.c | 2 +- src/cn_utils/crypto/crypto-ops.c | 2 +- src/cn_utils/crypto/crypto.cpp | 2 +- src/cn_utils/crypto/hash-ops.h | 2 +- src/cn_utils/cryptonote_core/account.cpp | 2 +- .../cryptonote_core/blockchain_storage.cpp | 2 +- .../cryptonote_core/cryptonote_core.cpp | 10 +++++----- .../cryptonote_core/cryptonote_core.h | 2 +- src/cn_utils/cryptonote_core/tx_pool.cpp | 2 +- .../cryptonote_protocol_handler.h | 4 ++-- src/cn_utils/p2p/net_node.h | 4 ++-- src/cn_utils/serialization/binary_archive.h | 2 +- 18 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 652bb4ce1..acdb10fff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,6 +28,7 @@ LIBBITCOIN_COMMON=libbitcoin_common.a LIBBITCOIN_CONSENSUS=libbitcoin_consensus.a LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a +LIBBITCOIN_CNUTILS=libbitcoin_cnutils.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a LIBBITCOINQT=qt/libbitcoinqt.a LIBSECP256K1=secp256k1/libsecp256k1.la @@ -50,6 +51,7 @@ $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) EXTRA_LIBRARIES += \ $(LIBBITCOIN_CRYPTO) \ $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CNUTILS) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_SERVER) \ @@ -366,6 +368,20 @@ libbitcoin_common_a_SOURCES = \ keva/common.cpp \ $(BITCOIN_CORE_H) +# cnutils: shared between bitcoind, and bitcoin-qt and non-server tools +libbitcoin_cnutils_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/cn_utils -I$(srcdir)/cn_utils/contrib -I$(srcdir)/cn_utils/contrib/epee/include +libbitcoin_cnutils_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +libbitcoin_cnutils_a_SOURCES = \ + cn_utils/cnutils.cpp \ + cn_utils/cryptonote_core/cryptonote_format_utils.cpp \ + cn_utils/crypto/tree-hash.c \ + cn_utils/crypto/crypto.cpp \ + cn_utils/crypto/crypto-ops.c \ + cn_utils/crypto/crypto-ops-data.c \ + cn_utils/crypto/hash.c \ + cn_utils/crypto/keccak.c \ + cn_utils/common/base58.cpp + # util: shared between all executables. # This library *must* be included to make sure that the glibc # backward-compatibility objects and their sanity checks are linked. @@ -420,6 +436,7 @@ kevacoind_LDADD = \ $(LIBBITCOIN_COMMON) \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CNUTILS) \ $(LIBBITCOIN_WALLET) \ $(LIBBITCOIN_ZMQ) \ $(LIBBITCOIN_CONSENSUS) \ @@ -445,6 +462,7 @@ kevacoin_cli_LDADD = \ $(LIBBITCOIN_CLI) \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CNUTILS) \ $(LIBBITCOIN_CRYPTO) kevacoin_cli_LDADD += $(BOOST_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS) @@ -464,6 +482,7 @@ kevacoin_tx_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CNUTILS) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBSECP256K1) diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index de150eda3..fd7195458 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -37,6 +37,7 @@ bench_bench_kevacoin_LDADD = \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CNUTILS) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBLEVELDB) \ diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 21290cede..c332f362f 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -436,7 +436,7 @@ endif if ENABLE_ZMQ qt_kevacoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif -qt_kevacoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \ +qt_kevacoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CNUTILS) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \ $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) qt_kevacoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) @@ -447,7 +447,7 @@ QT_QM=$(QT_TS:.ts=.qm) SECONDARY: $(QT_QM) -$(srcdir)/qt/bitcoinstrings.cpp: $(libbitcoin_server_a_SOURCES) $(libbitcoin_wallet_a_SOURCES) $(libbitcoin_common_a_SOURCES) $(libbitcoin_zmq_a_SOURCES) $(libbitcoin_consensus_a_SOURCES) $(libbitcoin_util_a_SOURCES) +$(srcdir)/qt/bitcoinstrings.cpp: $(libbitcoin_server_a_SOURCES) $(libbitcoin_wallet_a_SOURCES) $(libbitcoin_common_a_SOURCES) $(libbitcoin_zmq_a_SOURCES) $(libbitcoin_consensus_a_SOURCES) $(libbitcoin_util_a_SOURCES) $(libbitcoin_cnutils_a_SOURCES) @test -n $(XGETTEXT) || echo "xgettext is required for updating translations" $(AM_V_GEN) cd $(srcdir); XGETTEXT=$(XGETTEXT) PACKAGE_NAME="$(PACKAGE_NAME)" COPYRIGHT_HOLDERS="$(COPYRIGHT_HOLDERS)" COPYRIGHT_HOLDERS_SUBSTITUTION="$(COPYRIGHT_HOLDERS_SUBSTITUTION)" $(PYTHON) ../share/qt/extract_strings_qt.py $^ diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 4c7b2c355..732662b22 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -57,7 +57,7 @@ endif if ENABLE_ZMQ qt_test_test_kevacoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif -qt_test_test_kevacoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \ +qt_test_test_kevacoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CNUTILS) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \ $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 851818de2..e03cf7e9a 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -104,7 +104,7 @@ test_test_kevacoin_LDADD = if ENABLE_WALLET test_test_kevacoin_LDADD += $(LIBBITCOIN_WALLET) endif -test_test_kevacoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \ +test_test_kevacoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CNUTILS) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \ $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) test_test_kevacoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -127,6 +127,7 @@ test_test_kevacoin_fuzzy_LDADD = \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CNUTILS) \ $(LIBBITCOIN_CONSENSUS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBSECP256K1) diff --git a/src/cn_utils/contrib/epee/include/storages/portable_storage_val_converters.h b/src/cn_utils/contrib/epee/include/storages/portable_storage_val_converters.h index 6ea505886..e5ce70736 100644 --- a/src/cn_utils/contrib/epee/include/storages/portable_storage_val_converters.h +++ b/src/cn_utils/contrib/epee/include/storages/portable_storage_val_converters.h @@ -30,7 +30,7 @@ #include "misc_language.h" #include "portable_storage_base.h" -#include "warnings.h" +#include "epee/include/warnings.h" namespace epee { diff --git a/src/cn_utils/crypto/chacha8.c b/src/cn_utils/crypto/chacha8.c index df135af59..463aedc30 100644 --- a/src/cn_utils/crypto/chacha8.c +++ b/src/cn_utils/crypto/chacha8.c @@ -10,7 +10,7 @@ Public domain. #include "chacha8.h" #include "common/int-util.h" -#include "warnings.h" +#include "epee/include/warnings.h" /* * The following macros are used to obtain exact-width results. diff --git a/src/cn_utils/crypto/crypto-ops.c b/src/cn_utils/crypto/crypto-ops.c index 97e7df50e..8b51be52b 100644 --- a/src/cn_utils/crypto/crypto-ops.c +++ b/src/cn_utils/crypto/crypto-ops.c @@ -5,7 +5,7 @@ #include #include -#include "warnings.h" +#include "epee/include/warnings.h" #include "crypto-ops.h" DISABLE_VS_WARNINGS(4146 4244) diff --git a/src/cn_utils/crypto/crypto.cpp b/src/cn_utils/crypto/crypto.cpp index f7ca64681..453eb7ae4 100644 --- a/src/cn_utils/crypto/crypto.cpp +++ b/src/cn_utils/crypto/crypto.cpp @@ -12,7 +12,7 @@ #include #include "common/varint.h" -#include "warnings.h" +#include "epee/include/warnings.h" #include "crypto.h" #include "hash.h" diff --git a/src/cn_utils/crypto/hash-ops.h b/src/cn_utils/crypto/hash-ops.h index 4b737450d..59e5eeb8e 100644 --- a/src/cn_utils/crypto/hash-ops.h +++ b/src/cn_utils/crypto/hash-ops.h @@ -12,7 +12,7 @@ #include #include "common/int-util.h" -#include "warnings.h" +#include "epee/include/warnings.h" static inline void *padd(void *p, size_t i) { return (char *) p + i; diff --git a/src/cn_utils/cryptonote_core/account.cpp b/src/cn_utils/cryptonote_core/account.cpp index ba39b9b77..65573963e 100644 --- a/src/cn_utils/cryptonote_core/account.cpp +++ b/src/cn_utils/cryptonote_core/account.cpp @@ -8,7 +8,7 @@ #include "include_base_utils.h" #include "account.h" -#include "warnings.h" +#include "epee/include/warnings.h" #include "crypto/crypto.h" #include "cryptonote_core/cryptonote_basic_impl.h" #include "cryptonote_core/cryptonote_format_utils.h" diff --git a/src/cn_utils/cryptonote_core/blockchain_storage.cpp b/src/cn_utils/cryptonote_core/blockchain_storage.cpp index 0e20b454b..9f6e315b8 100644 --- a/src/cn_utils/cryptonote_core/blockchain_storage.cpp +++ b/src/cn_utils/cryptonote_core/blockchain_storage.cpp @@ -19,7 +19,7 @@ #include "profile_tools.h" #include "file_io_utils.h" #include "common/boost_serialization_helper.h" -#include "warnings.h" +#include "epee/include/warnings.h" #include "crypto/hash.h" //#include "serialization/json_archive.h" diff --git a/src/cn_utils/cryptonote_core/cryptonote_core.cpp b/src/cn_utils/cryptonote_core/cryptonote_core.cpp index a09f25d31..09cf4a924 100644 --- a/src/cn_utils/cryptonote_core/cryptonote_core.cpp +++ b/src/cn_utils/cryptonote_core/cryptonote_core.cpp @@ -11,7 +11,7 @@ using namespace epee; #include "cryptonote_core.h" #include "common/command_line.h" #include "common/util.h" -#include "warnings.h" +#include "epee/include/warnings.h" #include "crypto/crypto.h" #include "cryptonote_config.h" #include "cryptonote_format_utils.h" @@ -27,7 +27,7 @@ namespace cryptonote m_mempool(m_blockchain_storage), m_blockchain_storage(m_mempool), m_miner(this), - m_miner_address(boost::value_initialized()), + m_miner_address(boost::value_initialized()), m_starter_message_showed(false) { set_cryptonote_protocol(pprotocol); @@ -499,14 +499,14 @@ namespace cryptonote { if(!m_starter_message_showed) { - LOG_PRINT_L0(ENDL << "**********************************************************************" << ENDL - << "The daemon will start synchronizing with the network. It may take up to several hours." << ENDL + LOG_PRINT_L0(ENDL << "**********************************************************************" << ENDL + << "The daemon will start synchronizing with the network. It may take up to several hours." << ENDL << ENDL << "You can set the level of process detailization by using command \"set_log \", where is either 0 (no details), 1 (current block height synchronized), or 2 (all details)." << ENDL << ENDL << "Use \"help\" command to see the list of available commands." << ENDL << ENDL - << "Note: in case you need to interrupt the process, use \"exit\" command. Otherwise, the current progress won't be saved." << ENDL + << "Note: in case you need to interrupt the process, use \"exit\" command. Otherwise, the current progress won't be saved." << ENDL << "**********************************************************************"); m_starter_message_showed = true; } diff --git a/src/cn_utils/cryptonote_core/cryptonote_core.h b/src/cn_utils/cryptonote_core/cryptonote_core.h index c298451e8..b3c4fe26d 100644 --- a/src/cn_utils/cryptonote_core/cryptonote_core.h +++ b/src/cn_utils/cryptonote_core/cryptonote_core.h @@ -15,7 +15,7 @@ #include "miner.h" #include "connection_context.h" #include "cryptonote_core/cryptonote_stat_info.h" -#include "warnings.h" +#include "epee/include/warnings.h" #include "crypto/hash.h" PUSH_WARNINGS diff --git a/src/cn_utils/cryptonote_core/tx_pool.cpp b/src/cn_utils/cryptonote_core/tx_pool.cpp index 24e5752ad..99a839e30 100644 --- a/src/cn_utils/cryptonote_core/tx_pool.cpp +++ b/src/cn_utils/cryptonote_core/tx_pool.cpp @@ -15,7 +15,7 @@ #include "common/boost_serialization_helper.h" #include "common/int-util.h" #include "misc_language.h" -#include "warnings.h" +#include "epee/include/warnings.h" #include "crypto/hash.h" DISABLE_VS_WARNINGS(4244 4345 4503) //'boost::foreach_detail_::or_' : decorated name length exceeded, name was truncated diff --git a/src/cn_utils/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cn_utils/cryptonote_protocol/cryptonote_protocol_handler.h index 178ec2eb1..2bf1501dd 100644 --- a/src/cn_utils/cryptonote_protocol/cryptonote_protocol_handler.h +++ b/src/cn_utils/cryptonote_protocol/cryptonote_protocol_handler.h @@ -7,7 +7,7 @@ #include #include "storages/levin_abstract_invoke2.h" -#include "warnings.h" +#include "epee/include/warnings.h" #include "cryptonote_protocol_defs.h" #include "cryptonote_protocol_handler_common.h" #include "cryptonote_core/connection_context.h" @@ -22,7 +22,7 @@ namespace cryptonote template class t_cryptonote_protocol_handler: public i_cryptonote_protocol - { + { public: typedef cryptonote_connection_context connection_context; typedef core_stat_info stat_info; diff --git a/src/cn_utils/p2p/net_node.h b/src/cn_utils/p2p/net_node.h index 794b97429..604a89477 100644 --- a/src/cn_utils/p2p/net_node.h +++ b/src/cn_utils/p2p/net_node.h @@ -16,7 +16,7 @@ #include #include -#include "warnings.h" +#include "epee/include/warnings.h" #include "net/levin_server_cp2.h" #include "p2p_protocol_defs.h" #include "storages/levin_abstract_invoke2.h" @@ -142,7 +142,7 @@ namespace nodetool bool try_to_connect_and_handshake_with_new_peer(const net_address& na, bool just_take_peerlist = false, uint64_t last_seen_stamp = 0, bool white = true); size_t get_random_index_with_fixed_probability(size_t max_index); bool is_peer_used(const peerlist_entry& peer); - bool is_addr_connected(const net_address& peer); + bool is_addr_connected(const net_address& peer); template bool try_ping(basic_node_data& node_data, p2p_connection_context& context, t_callback cb); bool make_expected_connections_count(bool white_list, size_t expected_connections); diff --git a/src/cn_utils/serialization/binary_archive.h b/src/cn_utils/serialization/binary_archive.h index f28e45c0c..6af25ff55 100644 --- a/src/cn_utils/serialization/binary_archive.h +++ b/src/cn_utils/serialization/binary_archive.h @@ -13,7 +13,7 @@ #include #include "common/varint.h" -#include "warnings.h" +#include "epee/include/warnings.h" PUSH_WARNINGS DISABLE_VS_WARNINGS(4244)