From 470903a9c0101d7e1a646da39630adcffaf7a535 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Mon, 5 Jan 2015 22:27:46 -0600 Subject: [PATCH] Renaming client to node since we're all peers. --- CMakeLists.txt | 26 +- rai/cli/daemon.cpp | 4 +- rai/cli/daemon.hpp | 2 +- rai/cli/entry.cpp | 4 +- rai/core_test/conflicts.cpp | 6 +- rai/core_test/gap_cache.cpp | 26 +- rai/core_test/ledger.cpp | 60 +-- rai/core_test/message.cpp | 2 +- rai/core_test/message_parser.cpp | 6 +- rai/core_test/network.cpp | 300 ++++++------ rai/core_test/{client.cpp => node.cpp} | 136 +++--- rai/core_test/rpc.cpp | 106 ++--- rai/core_test/wallet.cpp | 16 +- rai/core_test/wallets.cpp | 10 +- rai/landing/entry.cpp | 8 +- rai/{core/core.cpp => node.cpp} | 632 ++++++++++++------------- rai/{core/core.hpp => node.hpp} | 78 +-- rai/qt/qt.cpp | 48 +- rai/qt/qt.hpp | 6 +- rai/qt_client/entry.cpp | 4 +- rai/qt_system/entry.cpp | 4 +- rai/qt_test/qt.cpp | 30 +- rai/slow_test/{client.cpp => node.cpp} | 10 +- 23 files changed, 762 insertions(+), 762 deletions(-) rename rai/core_test/{client.cpp => node.cpp} (63%) rename rai/{core/core.cpp => node.cpp} (86%) rename rai/{core/core.hpp => node.hpp} (93%) rename rai/slow_test/{client.cpp => node.cpp} (59%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 262cb313..7654112a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,9 +37,9 @@ add_library (secure rai/secure.cpp ) -add_library (core - rai/core/core.hpp - rai/core/core.cpp +add_library (node + rai/node.hpp + rai/node.cpp ed25519-donna/ed25519-hash-custom.h ed25519-donna/ed25519-randombytes-custom.h ed25519-donna/ed25519.h @@ -50,7 +50,7 @@ add_executable (core_test rai/core_test/block.cpp rai/core_test/block_store.cpp rai/core_test/block_synchronization.cpp - rai/core_test/client.cpp + rai/core_test/node.cpp rai/core_test/conflicts.cpp rai/core_test/daemon.cpp rai/core_test/entry.cpp @@ -68,7 +68,7 @@ add_executable (core_test ) add_executable (slow_test - rai/slow_test/client.cpp) + rai/slow_test/node.cpp) add_executable (qt_test rai/qt_test/qt.cpp) @@ -98,7 +98,7 @@ set (CPACK_PACKAGE_VERSION_PATCH "0") SET (ACTIVE_NETWORK rai_active_network CACHE STRING "Selects which network parameters are used") set_property (CACHE ACTIVE_NETWORK PROPERTY STRINGS rai_test_network rai_beta_network rai_live_network) -set_target_properties (secure core core_test slow_test qt_test cli qt qt_client qt_system landing PROPERTIES COMPILE_FLAGS "-std=c++11 -Werror=switch ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DED25519_CUSTOMHASH -DED25519_CUSTOMRNG -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DRAIBLOCKS_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}") +set_target_properties (secure node core_test slow_test qt_test cli qt qt_client qt_system landing PROPERTIES COMPILE_FLAGS "-std=c++11 -Werror=switch ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DED25519_CUSTOMHASH -DED25519_CUSTOMRNG -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DRAIBLOCKS_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}") set_target_properties (qt_client qt_test PROPERTIES LINK_FLAGS "${PLATFORM_GUI_EXE_LINK_FLAGS}") if (WIN32) @@ -107,19 +107,19 @@ else (WIN32) set (PLATFORM_LIBS) endif (WIN32) -target_link_libraries (core_test core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) +target_link_libraries (core_test node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) -target_link_libraries (slow_test core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) +target_link_libraries (slow_test node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) -target_link_libraries (cli core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) +target_link_libraries (cli node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) -target_link_libraries (landing core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) +target_link_libraries (landing node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) -target_link_libraries (qt_test core secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) +target_link_libraries (qt_test node secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) -target_link_libraries (qt_client core secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) +target_link_libraries (qt_client node secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) -target_link_libraries (qt_system core secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) +target_link_libraries (qt_system node secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY}) if (APPLE) get_filename_component (Qt5Core_framework_DIR ${Qt5_DIR}/../../QtCore.framework ABSOLUTE) diff --git a/rai/cli/daemon.cpp b/rai/cli/daemon.cpp index 490c74d4..29a96948 100644 --- a/rai/cli/daemon.cpp +++ b/rai/cli/daemon.cpp @@ -105,8 +105,8 @@ void rai_daemon::daemon::run (int argc, char * const * argv) auto service (boost::make_shared ()); auto pool (boost::make_shared ()); rai::processor_service processor; - rai::client_init init; - auto client (std::make_shared (init, service, config.peering_port, working, processor)); + rai::node_init init; + auto client (std::make_shared (init, service, config.peering_port, working, processor)); if (!init.error ()) { client->bootstrap_peers = config.bootstrap_peers; diff --git a/rai/cli/daemon.hpp b/rai/cli/daemon.hpp index 494040e0..32ac6452 100644 --- a/rai/cli/daemon.hpp +++ b/rai/cli/daemon.hpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/rai/cli/entry.cpp b/rai/cli/entry.cpp index c38ce144..af993b5c 100644 --- a/rai/cli/entry.cpp +++ b/rai/cli/entry.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -129,7 +129,7 @@ int main (int argc, char * const * argv) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); size_t count (10000); - system.generate_mass_activity (count, *system.clients [0]); + system.generate_mass_activity (count, *system.nodes [0]); } else if (vm.count ("generate_key")) { diff --git a/rai/core_test/conflicts.cpp b/rai/core_test/conflicts.cpp index 76af99a0..29005df6 100644 --- a/rai/core_test/conflicts.cpp +++ b/rai/core_test/conflicts.cpp @@ -4,7 +4,7 @@ TEST (conflicts, start_stop) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; @@ -31,7 +31,7 @@ TEST (conflicts, start_stop) TEST (conflicts, add_existing) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; @@ -67,7 +67,7 @@ TEST (conflicts, add_existing) TEST (conflicts, add_two) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; diff --git a/rai/core_test/gap_cache.cpp b/rai/core_test/gap_cache.cpp index 6eb75336..ab850944 100644 --- a/rai/core_test/gap_cache.cpp +++ b/rai/core_test/gap_cache.cpp @@ -4,7 +4,7 @@ TEST (gap_cache, add_new) { rai::system system (24000, 1); - rai::gap_cache cache (*system.clients [0]); + rai::gap_cache cache (*system.nodes [0]); rai::send_block block1; cache.add (rai::send_block (block1), block1.previous ()); ASSERT_NE (cache.blocks.end (), cache.blocks.find (block1.previous ())); @@ -13,7 +13,7 @@ TEST (gap_cache, add_new) TEST (gap_cache, add_existing) { rai::system system (24000, 1); - rai::gap_cache cache (*system.clients [0]); + rai::gap_cache cache (*system.nodes [0]); rai::send_block block1; auto previous (block1.previous ()); cache.add (block1, previous); @@ -31,7 +31,7 @@ TEST (gap_cache, add_existing) TEST (gap_cache, comparison) { rai::system system (24000, 1); - rai::gap_cache cache (*system.clients [0]); + rai::gap_cache cache (*system.nodes [0]); rai::send_block block1; block1.hashables.previous.clear (); auto previous1 (block1.previous ()); @@ -54,7 +54,7 @@ TEST (gap_cache, comparison) TEST (gap_cache, limit) { rai::system system (24000, 1); - rai::gap_cache cache (*system.clients [0]); + rai::gap_cache cache (*system.nodes [0]); for (auto i (0); i < cache.max * 2; ++i) { rai::send_block block1; @@ -69,7 +69,7 @@ TEST (gap_cache, gap_bootstrap) { rai::system system (24000, 2); auto iterations1 (0); - while (system.clients [0]->bootstrap_initiator.in_progress || system.clients [1]->bootstrap_initiator.in_progress) + while (system.nodes [0]->bootstrap_initiator.in_progress || system.nodes [1]->bootstrap_initiator.in_progress) { system.service->poll_one (); system.processor.poll_one (); @@ -80,19 +80,19 @@ TEST (gap_cache, gap_bootstrap) rai::send_block send; send.hashables.balance = std::numeric_limits ::max () - 100; send.hashables.destination = key.pub; - send.hashables.previous = system.clients [0]->ledger.latest (rai::test_genesis_key.pub); - system.clients [0]->work_create (send); + send.hashables.previous = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub); + system.nodes [0]->work_create (send); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send.hash (), send.signature); - ASSERT_EQ (rai::process_result::progress, system.clients [0]->processor.process_receive (send)); - ASSERT_EQ (std::numeric_limits ::max () - 100, system.clients [0]->ledger.account_balance (rai::genesis_account)); - ASSERT_EQ (std::numeric_limits ::max (), system.clients [1]->ledger.account_balance (rai::genesis_account)); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->processor.process_receive (send)); + ASSERT_EQ (std::numeric_limits ::max () - 100, system.nodes [0]->ledger.account_balance (rai::genesis_account)); + ASSERT_EQ (std::numeric_limits ::max (), system.nodes [1]->ledger.account_balance (rai::genesis_account)); system.wallet (0)->store.insert (rai::test_genesis_key.prv); system.wallet (0)->store.insert (key.prv); system.wallet (0)->send (key.pub, 100); - ASSERT_EQ (std::numeric_limits ::max () - 200, system.clients [0]->ledger.account_balance (rai::genesis_account)); - ASSERT_EQ (std::numeric_limits ::max (), system.clients [1]->ledger.account_balance (rai::genesis_account)); + ASSERT_EQ (std::numeric_limits ::max () - 200, system.nodes [0]->ledger.account_balance (rai::genesis_account)); + ASSERT_EQ (std::numeric_limits ::max (), system.nodes [1]->ledger.account_balance (rai::genesis_account)); auto iterations2 (0); - while (system.clients [1]->ledger.account_balance (rai::genesis_account) != std::numeric_limits ::max () - 200) + while (system.nodes [1]->ledger.account_balance (rai::genesis_account) != std::numeric_limits ::max () - 200) { system.service->poll_one (); system.processor.poll_one (); diff --git a/rai/core_test/ledger.cpp b/rai/core_test/ledger.cpp index 88653eb3..9a4b1759 100644 --- a/rai/core_test/ledger.cpp +++ b/rai/core_test/ledger.cpp @@ -76,7 +76,7 @@ TEST (ledger, checksum_persistence) TEST (system, system_genesis) { rai::system system (24000, 2); - for (auto & i: system.clients) + for (auto & i: system.nodes) { ASSERT_EQ (std::numeric_limits ::max (), i->ledger.account_balance (rai::genesis_account)); } @@ -578,13 +578,13 @@ TEST (system, generate_send_existing) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::frontier frontier1; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); - system.generate_send_existing (*system.clients [0]); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); + system.generate_send_existing (*system.nodes [0]); rai::frontier frontier2; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier2)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier2)); ASSERT_NE (frontier1.hash, frontier2.hash); auto iterations1 (0); - while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) == std::numeric_limits ::max ()) + while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) == std::numeric_limits ::max ()) { system.service->poll_one (); system.processor.poll_one (); @@ -592,7 +592,7 @@ TEST (system, generate_send_existing) ASSERT_LT (iterations1, 20); } auto iterations2 (0); - while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits ::max ()) + while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits ::max ()) { system.service->poll_one (); system.processor.poll_one (); @@ -605,10 +605,10 @@ TEST (system, generate_send_new) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); - auto iterator1 (system.clients [0]->store.latest_begin ()); + auto iterator1 (system.nodes [0]->store.latest_begin ()); ++iterator1; - ASSERT_EQ (system.clients [0]->store.latest_end (), iterator1); - system.generate_send_new (*system.clients [0]); + ASSERT_EQ (system.nodes [0]->store.latest_end (), iterator1); + system.generate_send_new (*system.nodes [0]); rai::account new_account; auto iterator2 (system.wallet (0)->store.begin ()); if (iterator2->first != rai::test_genesis_key.pub) @@ -624,7 +624,7 @@ TEST (system, generate_send_new) ++iterator2; ASSERT_EQ (system.wallet (0)->store.end (), iterator2); auto iterations (0); - while (system.clients [0]->ledger.account_balance (new_account) == 0) + while (system.nodes [0]->ledger.account_balance (new_account) == 0) { system.service->poll_one (); system.processor.poll_one (); @@ -795,7 +795,7 @@ TEST (ledegr, double_receive) TEST (votes, add_unsigned) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; @@ -819,7 +819,7 @@ TEST (votes, add_unsigned) TEST (votes, add_one) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; @@ -849,7 +849,7 @@ TEST (votes, add_one) TEST (votes, add_two) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; @@ -890,7 +890,7 @@ TEST (votes, add_two) TEST (votes, add_existing) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; @@ -929,7 +929,7 @@ TEST (votes, add_existing) TEST (votes, add_old) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block send1; rai::keypair key1; @@ -975,17 +975,17 @@ TEST (ledger, successor) send1.hashables.balance.clear (); send1.hashables.destination = key1.pub; rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send1.hash (), send1.signature); - ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (send1)); - ASSERT_EQ (send1, *system.clients [0]->ledger.successor (genesis.hash ())); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (send1)); + ASSERT_EQ (send1, *system.nodes [0]->ledger.successor (genesis.hash ())); } TEST (fork, publish) { - std::weak_ptr client0; + std::weak_ptr client0; { rai::system system (24000, 1); - client0 = system.clients [0]; - auto & client1 (*system.clients [0]); + client0 = system.nodes [0]; + auto & client1 (*system.nodes [0]); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::keypair key1; rai::genesis genesis; @@ -1032,8 +1032,8 @@ TEST (fork, publish) TEST (ledger, fork_keep) { rai::system system (24000, 2); - auto & client1 (*system.clients [0]); - auto & client2 (*system.clients [1]); + auto & client1 (*system.nodes [0]); + auto & client2 (*system.nodes [1]); ASSERT_EQ (1, client1.peers.size ()); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::keypair key1; @@ -1068,8 +1068,8 @@ TEST (ledger, fork_keep) auto votes1 (conflict->second); ASSERT_NE (nullptr, votes1); ASSERT_EQ (1, votes1->votes.rep_votes.size ()); - ASSERT_TRUE (system.clients [0]->store.block_exists (publish1.block->hash ())); - ASSERT_TRUE (system.clients [1]->store.block_exists (publish1.block->hash ())); + ASSERT_TRUE (system.nodes [0]->store.block_exists (publish1.block->hash ())); + ASSERT_TRUE (system.nodes [1]->store.block_exists (publish1.block->hash ())); auto iterations (0); while (votes1->votes.rep_votes.size () == 1) { @@ -1081,15 +1081,15 @@ TEST (ledger, fork_keep) auto winner (client1.ledger.winner (votes1->votes)); ASSERT_EQ (*publish1.block, *winner.second); ASSERT_EQ (std::numeric_limits ::max (), winner.first); - ASSERT_TRUE (system.clients [0]->store.block_exists (publish1.block->hash ())); - ASSERT_TRUE (system.clients [1]->store.block_exists (publish1.block->hash ())); + ASSERT_TRUE (system.nodes [0]->store.block_exists (publish1.block->hash ())); + ASSERT_TRUE (system.nodes [1]->store.block_exists (publish1.block->hash ())); } TEST (ledger, fork_flip) { rai::system system (24000, 2); - auto & client1 (*system.clients [0]); - auto & client2 (*system.clients [1]); + auto & client1 (*system.nodes [0]); + auto & client2 (*system.nodes [1]); ASSERT_EQ (1, client1.peers.size ()); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::keypair key1; @@ -1145,8 +1145,8 @@ TEST (ledger, fork_flip) TEST (ledger, fork_multi_flip) { rai::system system (24000, 2); - auto & client1 (*system.clients [0]); - auto & client2 (*system.clients [1]); + auto & client1 (*system.nodes [0]); + auto & client2 (*system.nodes [1]); ASSERT_EQ (1, client1.peers.size ()); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::keypair key1; diff --git a/rai/core_test/message.cpp b/rai/core_test/message.cpp index 45d7a3bf..97c004bb 100644 --- a/rai/core_test/message.cpp +++ b/rai/core_test/message.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST (message, keepalive_serialization) { diff --git a/rai/core_test/message_parser.cpp b/rai/core_test/message_parser.cpp index 62417dc9..97146251 100644 --- a/rai/core_test/message_parser.cpp +++ b/rai/core_test/message_parser.cpp @@ -60,7 +60,7 @@ TEST (message_parser, exact_confirm_ack_size) rai::message_parser parser (visitor); auto block (std::unique_ptr (new rai::send_block)); block->hashables.previous = 1; - system.clients [0]->work_create (*block); + system.nodes [0]->work_create (*block); rai::confirm_ack message (std::move (block)); std::vector bytes; { @@ -85,7 +85,7 @@ TEST (message_parser, exact_confirm_req_size) rai::message_parser parser (visitor); auto block (std::unique_ptr (new rai::send_block)); block->hashables.previous = 1; - system.clients [0]->work_create (*block); + system.nodes [0]->work_create (*block); rai::confirm_req message (std::move (block)); std::vector bytes; { @@ -110,7 +110,7 @@ TEST (message_parser, exact_publish_size) rai::message_parser parser (visitor); auto block (std::unique_ptr (new rai::send_block)); block->hashables.previous = 1; - system.clients [0]->work_create (*block); + system.nodes [0]->work_create (*block); rai::publish message (std::move (block)); std::vector bytes; { diff --git a/rai/core_test/network.cpp b/rai/core_test/network.cpp index e9048b8f..74b1bb05 100644 --- a/rai/core_test/network.cpp +++ b/rai/core_test/network.cpp @@ -48,59 +48,59 @@ TEST (network, tcp_connection) TEST (network, construction) { rai::system system (24000, 1); - ASSERT_EQ (1, system.clients.size ()); - ASSERT_EQ (24000, system.clients [0]->network.socket.local_endpoint ().port ()); + ASSERT_EQ (1, system.nodes.size ()); + ASSERT_EQ (24000, system.nodes [0]->network.socket.local_endpoint ().port ()); } TEST (network, self_discard) { rai::system system (24000, 1); - system.clients [0]->network.remote = system.clients [0]->network.endpoint (); - ASSERT_EQ (0, system.clients [0]->network.bad_sender_count); - system.clients [0]->network.receive_action (boost::system::error_code {}, 0); - ASSERT_EQ (1, system.clients [0]->network.bad_sender_count); + system.nodes [0]->network.remote = system.nodes [0]->network.endpoint (); + ASSERT_EQ (0, system.nodes [0]->network.bad_sender_count); + system.nodes [0]->network.receive_action (boost::system::error_code {}, 0); + ASSERT_EQ (1, system.nodes [0]->network.bad_sender_count); } TEST (network, send_keepalive) { rai::system system (24000, 1); - auto list1 (system.clients [0]->peers.list ()); + auto list1 (system.nodes [0]->peers.list ()); ASSERT_EQ (0, list1.size ()); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); client1->start (); - system.clients [0]->network.send_keepalive (client1->network.endpoint ()); - auto initial (system.clients [0]->network.keepalive_count); - ASSERT_EQ (0, system.clients [0]->peers.list ().size ()); + system.nodes [0]->network.send_keepalive (client1->network.endpoint ()); + auto initial (system.nodes [0]->network.keepalive_count); + ASSERT_EQ (0, system.nodes [0]->peers.list ().size ()); ASSERT_EQ (0, client1->peers.list ().size ()); auto iterations (0); - while (system.clients [0]->network.keepalive_count == initial) + while (system.nodes [0]->network.keepalive_count == initial) { system.service->poll_one (); ++iterations; ASSERT_LT (iterations, 200); } - auto peers1 (system.clients [0]->peers.list ()); + auto peers1 (system.nodes [0]->peers.list ()); auto peers2 (client1->peers.list ()); ASSERT_EQ (1, peers1.size ()); ASSERT_EQ (1, peers2.size ()); ASSERT_NE (peers1.end (), std::find_if (peers1.begin (), peers1.end (), [&client1] (rai::peer_information const & information_a) {return information_a.endpoint == client1->network.endpoint ();})); - ASSERT_NE (peers2.end (), std::find_if (peers2.begin (), peers2.end (), [&system] (rai::peer_information const & information_a) {return information_a.endpoint == system.clients [0]->network.endpoint ();})); + ASSERT_NE (peers2.end (), std::find_if (peers2.begin (), peers2.end (), [&system] (rai::peer_information const & information_a) {return information_a.endpoint == system.nodes [0]->network.endpoint ();})); client1->stop (); } TEST (network, keepalive_ipv4) { rai::system system (24000, 1); - auto list1 (system.clients [0]->peers.list ()); + auto list1 (system.nodes [0]->peers.list ()); ASSERT_EQ (0, list1.size ()); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); client1->start (); client1->send_keepalive (rai::endpoint (boost::asio::ip::address_v4::loopback (), 24000)); - auto initial (system.clients [0]->network.keepalive_count); + auto initial (system.nodes [0]->network.keepalive_count); auto iterations (0); - while (system.clients [0]->network.keepalive_count == initial) + while (system.nodes [0]->network.keepalive_count == initial) { system.service->poll_one (); ++iterations; @@ -112,30 +112,30 @@ TEST (network, keepalive_ipv4) TEST (network, multi_keepalive) { rai::system system (24000, 1); - auto list1 (system.clients [0]->peers.list ()); + auto list1 (system.nodes [0]->peers.list ()); ASSERT_EQ (0, list1.size ()); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); ASSERT_FALSE (init1.error ()); client1->start (); ASSERT_EQ (0, client1->peers.size ()); - client1->network.send_keepalive (system.clients [0]->network.endpoint ()); + client1->network.send_keepalive (system.nodes [0]->network.endpoint ()); ASSERT_EQ (0, client1->peers.size ()); - ASSERT_EQ (0, system.clients [0]->peers.size ()); + ASSERT_EQ (0, system.nodes [0]->peers.size ()); auto iterations1 (0); - while (system.clients [0]->peers.size () != 1) + while (system.nodes [0]->peers.size () != 1) { system.service->poll_one (); ++iterations1; ASSERT_LT (iterations1, 200); } - rai::client_init init2; - auto client2 (std::make_shared (init2, system.service, 24002, system.processor)); + rai::node_init init2; + auto client2 (std::make_shared (init2, system.service, 24002, system.processor)); ASSERT_FALSE (init2.error ()); client2->start (); - client2->network.send_keepalive (system.clients [0]->network.endpoint ()); + client2->network.send_keepalive (system.nodes [0]->network.endpoint ()); auto iterations2 (0); - while (client1->peers.size () != 2 || system.clients [0]->peers.size () != 2 || client2->peers.size () != 2) + while (client1->peers.size () != 2 || system.nodes [0]->peers.size () != 2 || client2->peers.size () != 2) { system.service->poll_one (); ++iterations2; @@ -150,20 +150,20 @@ TEST (network, send_discarded_publish) rai::system system (24000, 2); std::unique_ptr block (new rai::send_block); block->hashables.previous = 1; - system.clients [0]->work_create (*block); - system.clients [0]->network.republish_block (std::move (block)); + system.nodes [0]->work_create (*block); + system.nodes [0]->network.republish_block (std::move (block)); rai::genesis genesis; - ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); - ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub)); auto iterations (0); - while (system.clients [1]->network.publish_count == 0) + while (system.nodes [1]->network.publish_count == 0) { system.service->poll_one (); ++iterations; ASSERT_LT (iterations, 200); } - ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); - ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub)); } TEST (network, send_invalid_publish) @@ -172,21 +172,21 @@ TEST (network, send_invalid_publish) std::unique_ptr block (new rai::send_block); block->hashables.previous = 1; block->hashables.balance = 20; - system.clients [0]->work_create (*block); + system.nodes [0]->work_create (*block); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, block->hash (), block->signature); - system.clients [0]->network.republish_block (std::move (block)); + system.nodes [0]->network.republish_block (std::move (block)); rai::genesis genesis; - ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); - ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub)); auto iterations (0); - while (system.clients [1]->network.publish_count == 0) + while (system.nodes [1]->network.publish_count == 0) { system.service->poll_one (); ++iterations; ASSERT_LT (iterations, 200); } - ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); - ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub)); } TEST (network, send_valid_confirm_ack) @@ -197,28 +197,28 @@ TEST (network, send_valid_confirm_ack) system.wallet (1)->store.insert (key2.prv); rai::send_block block2; rai::frontier frontier1; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); block2.hashables.previous = frontier1.hash; block2.hashables.balance = 50; block2.hashables.destination = key2.pub; - system.clients [0]->work_create (block2); + system.nodes [0]->work_create (block2); auto hash2 (block2.hash ()); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, hash2, block2.signature); rai::frontier frontier2; - ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier2)); - system.clients [0]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (block2))); + ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier2)); + system.nodes [0]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (block2))); auto iterations (0); - while (system.clients [1]->network.confirm_ack_count == 0) + while (system.nodes [1]->network.confirm_ack_count == 0) { system.service->poll_one (); ++iterations; ASSERT_LT (iterations, 200); } rai::frontier frontier3; - ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier3)); + ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier3)); ASSERT_FALSE (frontier2.hash == frontier3.hash); ASSERT_EQ (hash2, frontier3.hash); - ASSERT_EQ (50, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (50, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub)); } TEST (network, send_valid_publish) @@ -229,28 +229,28 @@ TEST (network, send_valid_publish) system.wallet (1)->store.insert (key2.prv); rai::send_block block2; rai::frontier frontier1; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); block2.hashables.previous = frontier1.hash; block2.hashables.balance = 50; block2.hashables.destination = key2.pub; - system.clients [0]->work_create (block2); + system.nodes [0]->work_create (block2); auto hash2 (block2.hash ()); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, hash2, block2.signature); rai::frontier frontier2; - ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier2)); - system.clients [1]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (block2))); + ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier2)); + system.nodes [1]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (block2))); auto iterations (0); - while (system.clients [0]->network.publish_count == 0) + while (system.nodes [0]->network.publish_count == 0) { system.service->poll_one (); ++iterations; ASSERT_LT (iterations, 200); } rai::frontier frontier3; - ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier3)); + ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier3)); ASSERT_FALSE (frontier2.hash == frontier3.hash); ASSERT_EQ (hash2, frontier3.hash); - ASSERT_EQ (50, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (50, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub)); } TEST (network, send_insufficient_work) @@ -266,23 +266,23 @@ TEST (network, send_insufficient_work) rai::vectorstream stream (*bytes); publish.serialize (stream); } - auto client (system.clients [1]->shared ()); - system.clients [0]->network.send_buffer (bytes->data (), bytes->size (), system.clients [1]->network.endpoint (), [bytes, client] (boost::system::error_code const & ec, size_t size) {}); - ASSERT_EQ (0, system.clients [0]->network.insufficient_work_count); + auto client (system.nodes [1]->shared ()); + system.nodes [0]->network.send_buffer (bytes->data (), bytes->size (), system.nodes [1]->network.endpoint (), [bytes, client] (boost::system::error_code const & ec, size_t size) {}); + ASSERT_EQ (0, system.nodes [0]->network.insufficient_work_count); auto iterations (0); - while (system.clients [1]->network.insufficient_work_count == 0) + while (system.nodes [1]->network.insufficient_work_count == 0) { system.service->poll_one (); ++iterations; ASSERT_LT (iterations, 200); } - ASSERT_EQ (1, system.clients [1]->network.insufficient_work_count); + ASSERT_EQ (1, system.nodes [1]->network.insufficient_work_count); } TEST (receivable_processor, confirm_insufficient_pos) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block block1; block1.hashables.previous = genesis.hash (); @@ -301,7 +301,7 @@ TEST (receivable_processor, confirm_insufficient_pos) TEST (receivable_processor, confirm_sufficient_pos) { rai::system system (24000, 1); - auto & client1 (*system.clients [0]); + auto & client1 (*system.nodes [0]); rai::genesis genesis; rai::send_block block1; block1.hashables.previous = genesis.hash (); @@ -326,34 +326,34 @@ TEST (receivable_processor, send_with_receive) system.wallet (1)->store.insert (key2.prv); auto block1 (new rai::send_block ()); rai::frontier frontier1; - ASSERT_FALSE (system.clients [0]->ledger.store.latest_get (rai::test_genesis_key.pub, frontier1)); + ASSERT_FALSE (system.nodes [0]->ledger.store.latest_get (rai::test_genesis_key.pub, frontier1)); block1->hashables.previous = frontier1.hash; block1->hashables.balance = amount - 100; block1->hashables.destination = key2.pub; - system.clients [0]->work_create (*block1); + system.nodes [0]->work_create (*block1); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, block1->hash (), block1->signature); - ASSERT_EQ (amount, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_EQ (0, system.clients [0]->ledger.account_balance (key2.pub)); - ASSERT_EQ (amount, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_EQ (0, system.clients [1]->ledger.account_balance (key2.pub)); - system.clients [0]->processor.process_receive_republish (block1->clone ()); - system.clients [1]->processor.process_receive_republish (block1->clone ()); - ASSERT_EQ (amount - 100, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_EQ (0, system.clients [0]->ledger.account_balance (key2.pub)); - ASSERT_EQ (amount - 100, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_EQ (0, system.clients [1]->ledger.account_balance (key2.pub)); + ASSERT_EQ (amount, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (0, system.nodes [0]->ledger.account_balance (key2.pub)); + ASSERT_EQ (amount, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (0, system.nodes [1]->ledger.account_balance (key2.pub)); + system.nodes [0]->processor.process_receive_republish (block1->clone ()); + system.nodes [1]->processor.process_receive_republish (block1->clone ()); + ASSERT_EQ (amount - 100, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (0, system.nodes [0]->ledger.account_balance (key2.pub)); + ASSERT_EQ (amount - 100, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (0, system.nodes [1]->ledger.account_balance (key2.pub)); auto iterations (0); - while (system.clients [0]->ledger.account_balance (key2.pub) != 100) + while (system.nodes [0]->ledger.account_balance (key2.pub) != 100) { system.service->poll_one (); system.processor.poll_one (); ++iterations; ASSERT_LT (iterations, 200); } - ASSERT_EQ (amount - 100, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_EQ (100, system.clients [0]->ledger.account_balance (key2.pub)); - ASSERT_EQ (amount - 100, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_EQ (100, system.clients [1]->ledger.account_balance (key2.pub)); + ASSERT_EQ (amount - 100, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (100, system.nodes [0]->ledger.account_balance (key2.pub)); + ASSERT_EQ (amount - 100, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (100, system.nodes [1]->ledger.account_balance (key2.pub)); } TEST (network, receive_weight_change) @@ -365,7 +365,7 @@ TEST (network, receive_weight_change) system.wallet (1)->store.representative_set (key2.pub); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 2)); auto iterations (0); - while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr const & client_a) {return client_a->ledger.weight (key2.pub) != 2;})) + while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr const & node_a) {return node_a->ledger.weight (key2.pub) != 2;})) { system.service->poll_one (); system.processor.poll_one (); @@ -428,7 +428,7 @@ TEST (parse_endpoint, no_colon) TEST (bulk_pull, no_address) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::bulk_pull); req->start = 1; req->end = 2; @@ -441,20 +441,20 @@ TEST (bulk_pull, no_address) TEST (bulk_pull, genesis_to_end) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::bulk_pull {}); req->start = rai::test_genesis_key.pub; req->end.clear (); connection->requests.push (std::unique_ptr {}); auto request (std::make_shared (connection, std::move (req))); - ASSERT_EQ (system.clients [0]->ledger.latest (rai::test_genesis_key.pub), request->current); + ASSERT_EQ (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub), request->current); ASSERT_EQ (request->request->end, request->request->end); } TEST (bulk_pull, no_end) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::bulk_pull {}); req->start = rai::test_genesis_key.pub; req->end = 1; @@ -472,10 +472,10 @@ TEST (bulk_pull, end_not_owned) ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100)); rai::open_block open; open.hashables.representative = key2.pub; - open.hashables.source = system.clients [0]->ledger.latest (rai::test_genesis_key.pub); + open.hashables.source = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub); rai::sign_message (key2.prv, key2.pub, open.hash (), open.signature); - ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (open)); - auto connection (std::make_shared (nullptr, system.clients [0])); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (open)); + auto connection (std::make_shared (nullptr, system.nodes [0])); rai::genesis genesis; std::unique_ptr req (new rai::bulk_pull {}); req->start = key2.pub; @@ -488,7 +488,7 @@ TEST (bulk_pull, end_not_owned) TEST (bulk_pull, none) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); rai::genesis genesis; std::unique_ptr req (new rai::bulk_pull {}); req->start = genesis.hash (); @@ -502,7 +502,7 @@ TEST (bulk_pull, none) TEST (bulk_pull, get_next_on_open) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::bulk_pull {}); req->start = rai::test_genesis_key.pub; req->end.clear (); @@ -519,11 +519,11 @@ TEST (bulk_pull, get_next_on_open) TEST (bootstrap_processor, DISABLED_process_none) { rai::system system (24000, 1); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); ASSERT_FALSE (init1.error ()); auto done (false); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); while (!done) { system.service->run_one (); @@ -534,7 +534,7 @@ TEST (bootstrap_processor, DISABLED_process_none) TEST (bootstrap_processor, DISABLED_process_incomplete) { rai::system system (24000, 1); - auto client (std::make_shared (system.clients [0])); + auto client (std::make_shared (system.nodes [0])); rai::genesis genesis; auto frontier_req_client (std::make_shared (client)); frontier_req_client->pulls [rai::test_genesis_key.pub] = genesis.hash (); @@ -548,12 +548,12 @@ TEST (bootstrap_processor, process_one) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); ASSERT_FALSE (system.wallet (0)->send (rai::test_genesis_key.pub, 100)); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); - auto hash1 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + auto hash1 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); auto hash2 (client1->ledger.latest (rai::test_genesis_key.pub)); ASSERT_NE (hash1, hash2); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); auto iterations (0); while (client1->ledger.latest (rai::test_genesis_key.pub) != hash1) { @@ -570,18 +570,18 @@ TEST (bootstrap_processor, process_two) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); - auto hash1 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); + auto hash1 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); ASSERT_FALSE (system.wallet (0)->send (rai::test_genesis_key.pub, 50)); - auto hash2 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); + auto hash2 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); ASSERT_FALSE (system.wallet (0)->send (rai::test_genesis_key.pub, 50)); - auto hash3 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub)); + auto hash3 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)); ASSERT_NE (hash1, hash2); ASSERT_NE (hash1, hash3); ASSERT_NE (hash2, hash3); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); ASSERT_FALSE (init1.error ()); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); auto iterations (0); while (client1->ledger.latest (rai::test_genesis_key.pub) != hash3) { @@ -602,19 +602,19 @@ TEST (bootstrap_processor, process_new) system.wallet (1)->store.insert (key2.prv); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100)); auto iterations1 (0); - while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ()) + while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ()) { system.service->poll_one (); system.processor.poll_one (); ++iterations1; ASSERT_LT (iterations1, 200); } - auto balance1 (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - auto balance2 (system.clients [0]->ledger.account_balance (key2.pub)); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24002, system.processor)); + auto balance1 (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + auto balance2 (system.nodes [0]->ledger.account_balance (key2.pub)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24002, system.processor)); ASSERT_FALSE (init1.error ()); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); auto iterations2 (0); while (client1->ledger.account_balance (key2.pub) != balance2) { @@ -632,34 +632,34 @@ TEST (bootstrap_processor, diamond) rai::system system (24000, 1); rai::keypair key; std::unique_ptr send1 (new rai::send_block); - send1->hashables.previous = system.clients [0]->ledger.latest (rai::test_genesis_key.pub); + send1->hashables.previous = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub); send1->hashables.destination = key.pub; send1->hashables.balance = 100; rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send1->hash (), send1->signature); - system.clients [0]->work_create (*send1); - ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*send1)); + system.nodes [0]->work_create (*send1); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*send1)); std::unique_ptr send2 (new rai::send_block); send2->hashables.previous = send1->hash (); send2->hashables.destination = key.pub; send2->hashables.balance = 0; - system.clients [0]->work_create (*send2); + system.nodes [0]->work_create (*send2); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send2->hash (), send2->signature); - ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*send2)); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*send2)); std::unique_ptr open (new rai::open_block); open->hashables.source = send1->hash (); - system.clients [0]->work_create (*open); + system.nodes [0]->work_create (*open); rai::sign_message (key.prv, key.pub, open->hash (), open->signature); - ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*open)); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*open)); std::unique_ptr receive (new rai::receive_block); receive->hashables.previous = open->hash (); receive->hashables.source = send2->hash (); rai::sign_message (key.prv, key.pub, receive->hash (), receive->signature); - system.clients [0]->work_create (*receive); - ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*receive)); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24002, system.processor)); + system.nodes [0]->work_create (*receive); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*receive)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24002, system.processor)); ASSERT_FALSE (init1.error ()); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); auto iterations (0); while (client1->ledger.account_balance (key.pub) != std::numeric_limits ::max ()) { @@ -675,18 +675,18 @@ TEST (bootstrap_processor, diamond) TEST (bootstrap_processor, push_one) { rai::system system (24000, 1); - rai::client_init init1; + rai::node_init init1; rai::keypair key1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); auto wallet (client1->wallets.create (rai::uint256_union ())); ASSERT_NE (nullptr, wallet); wallet->store.insert (rai::test_genesis_key.prv); auto balance (client1->ledger.account_balance (rai::test_genesis_key.pub)); ASSERT_FALSE (wallet->send (key1.pub, 100)); ASSERT_NE (balance, client1->ledger.account_balance (rai::test_genesis_key.pub)); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); auto iterations (0); - while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance) + while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance) { system.service->poll_one (); ++iterations; @@ -701,7 +701,7 @@ TEST (frontier_req_response, destruction) std::shared_ptr hold; { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::frontier_req); req->start.clear (); req->age = std::numeric_limits age)>::max (); @@ -716,14 +716,14 @@ TEST (frontier_req_response, destruction) TEST (frontier_req, begin) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::frontier_req); req->start.clear (); req->age = std::numeric_limits age)>::max (); req->count = std::numeric_limits count)>::max (); connection->requests.push (std::unique_ptr {}); auto request (std::make_shared (connection, std::move (req))); - ASSERT_EQ (connection->client->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator); + ASSERT_EQ (connection->node->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator); auto pair (request->get_next ()); ASSERT_EQ (rai::test_genesis_key.pub, pair.first); rai::genesis genesis; @@ -733,14 +733,14 @@ TEST (frontier_req, begin) TEST (frontier_req, end) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::frontier_req); req->start = rai::test_genesis_key.pub.number () + 1; req->age = std::numeric_limits age)>::max (); req->count = std::numeric_limits count)>::max (); connection->requests.push (std::unique_ptr {}); auto request (std::make_shared (connection, std::move (req))); - ASSERT_EQ (connection->client->ledger.store.latest_end (), request->iterator); + ASSERT_EQ (connection->node->ledger.store.latest_end (), request->iterator); auto pair (request->get_next ()); ASSERT_TRUE (pair.first.is_zero ()); } @@ -748,14 +748,14 @@ TEST (frontier_req, end) TEST (frontier_req, time_bound) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::frontier_req); req->start.clear (); req->age = 0; req->count = std::numeric_limits count)>::max (); connection->requests.push (std::unique_ptr {}); auto request (std::make_shared (connection, std::move (req))); - ASSERT_EQ (connection->client->ledger.store.latest_end (), request->iterator); + ASSERT_EQ (connection->node->ledger.store.latest_end (), request->iterator); auto pair (request->get_next ()); ASSERT_TRUE (pair.first.is_zero ()); } @@ -763,14 +763,14 @@ TEST (frontier_req, time_bound) TEST (frontier_req, time_cutoff) { rai::system system (24000, 1); - auto connection (std::make_shared (nullptr, system.clients [0])); + auto connection (std::make_shared (nullptr, system.nodes [0])); std::unique_ptr req (new rai::frontier_req); req->start.clear (); req->age = 10; req->count = std::numeric_limits count)>::max (); connection->requests.push (std::unique_ptr {}); auto request (std::make_shared (connection, std::move (req))); - ASSERT_EQ (connection->client->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator); + ASSERT_EQ (connection->node->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator); auto pair (request->get_next ()); ASSERT_EQ (rai::test_genesis_key.pub, pair.first); rai::genesis genesis; @@ -781,28 +781,28 @@ TEST (bulk, genesis) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); ASSERT_FALSE (init1.error ()); rai::frontier frontier1; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); rai::frontier frontier2; ASSERT_FALSE (client1->store.latest_get (rai::test_genesis_key.pub, frontier2)); ASSERT_EQ (frontier1.hash, frontier2.hash); rai::keypair key2; ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100)); rai::frontier frontier3; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier3)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier3)); ASSERT_NE (frontier1.hash, frontier3.hash); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); auto iterations (0); - while (client1->ledger.latest (rai::test_genesis_key.pub) != system.clients [0]->ledger.latest (rai::test_genesis_key.pub)) + while (client1->ledger.latest (rai::test_genesis_key.pub) != system.nodes [0]->ledger.latest (rai::test_genesis_key.pub)) { system.service->poll_one (); ++iterations; ASSERT_LT (iterations, 200); } - ASSERT_EQ (system.clients [0]->ledger.latest (rai::test_genesis_key.pub), client1->ledger.latest (rai::test_genesis_key.pub)); + ASSERT_EQ (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub), client1->ledger.latest (rai::test_genesis_key.pub)); client1->stop (); } @@ -810,10 +810,10 @@ TEST (bulk, offline_send) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); ASSERT_FALSE (init1.error ()); - client1->network.send_keepalive (system.clients [0]->network.endpoint ()); + client1->network.send_keepalive (system.nodes [0]->network.endpoint ()); client1->start (); auto iterations (0); do @@ -822,13 +822,13 @@ TEST (bulk, offline_send) system.processor.poll_one (); ++iterations; ASSERT_LT (iterations, 200); - } while (system.clients [0]->peers.empty () || client1->peers.empty ()); + } while (system.nodes [0]->peers.empty () || client1->peers.empty ()); rai::keypair key2; auto wallet (client1->wallets.create (rai::uint256_union ())); wallet->store.insert (key2.prv); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100)); - ASSERT_NE (std::numeric_limits ::max (), system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ()); + ASSERT_NE (std::numeric_limits ::max (), system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ()); auto iterations2 (0); while (client1->ledger.account_balance (key2.pub) != 100) { diff --git a/rai/core_test/client.cpp b/rai/core_test/node.cpp similarity index 63% rename from rai/core_test/client.cpp rename to rai/core_test/node.cpp index 2843092e..855f7475 100644 --- a/rai/core_test/client.cpp +++ b/rai/core_test/node.cpp @@ -1,33 +1,33 @@ #include -#include +#include -TEST (client, stop) +TEST (node, stop) { rai::system system (24000, 1); - ASSERT_NE (system.clients [0]->wallets.items.end (), system.clients [0]->wallets.items.begin ()); - system.clients [0]->stop (); + ASSERT_NE (system.nodes [0]->wallets.items.end (), system.nodes [0]->wallets.items.begin ()); + system.nodes [0]->stop (); system.processor.run (); system.service->run (); ASSERT_TRUE (true); } -TEST (client, block_store_path_failure) +TEST (node, block_store_path_failure) { - rai::client_init init; + rai::node_init init; rai::processor_service processor; auto service (boost::make_shared ()); - auto client (std::make_shared (init, service, 0, boost::filesystem::path {}, processor)); - client->stop (); + auto node (std::make_shared (init, service, 0, boost::filesystem::path {}, processor)); + node->stop (); } -TEST (client, balance) +TEST (node, balance) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); - ASSERT_EQ (std::numeric_limits ::max (), system.wallet (0)->store.balance (system.clients [0]->ledger)); + ASSERT_EQ (std::numeric_limits ::max (), system.wallet (0)->store.balance (system.nodes [0]->ledger)); } -TEST (client, send_unkeyed) +TEST (node, send_unkeyed) { rai::system system (24000, 1); rai::keypair key2; @@ -36,7 +36,7 @@ TEST (client, send_unkeyed) ASSERT_TRUE (system.wallet (0)->send (key2.pub, 1000)); } -TEST (client, send_self) +TEST (node, send_self) { rai::system system (24000, 1); rai::keypair key2; @@ -44,27 +44,27 @@ TEST (client, send_self) system.wallet (0)->store.insert (key2.prv); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000)); auto iterations (0); - while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ()) + while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ()) { system.service->poll_one (); system.processor.poll_one (); ++iterations; ASSERT_LT (iterations, 200); } - ASSERT_EQ (std::numeric_limits ::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (std::numeric_limits ::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); } -TEST (client, send_single) +TEST (node, send_single) { rai::system system (24000, 2); rai::keypair key2; system.wallet (0)->store.insert (rai::test_genesis_key.prv); system.wallet (1)->store.insert (key2.prv); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000)); - ASSERT_EQ (std::numeric_limits ::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_TRUE (system.clients [0]->ledger.account_balance (key2.pub).is_zero ()); + ASSERT_EQ (std::numeric_limits ::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_TRUE (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ()); auto iterations (0); - while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ()) + while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ()) { system.service->poll_one (); system.processor.poll_one (); @@ -73,17 +73,17 @@ TEST (client, send_single) } } -TEST (client, send_single_observing_peer) +TEST (node, send_single_observing_peer) { rai::system system (24000, 3); rai::keypair key2; system.wallet (0)->store.insert (rai::test_genesis_key.prv); system.wallet (1)->store.insert (key2.prv); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000)); - ASSERT_EQ (std::numeric_limits ::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_TRUE (system.clients [0]->ledger.account_balance (key2.pub).is_zero ()); + ASSERT_EQ (std::numeric_limits ::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_TRUE (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ()); auto iterations (0); - while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr const & client_a) {return client_a->ledger.account_balance (key2.pub).is_zero();})) + while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr const & node_a) {return node_a->ledger.account_balance (key2.pub).is_zero();})) { system.service->poll_one (); system.processor.poll_one (); @@ -92,17 +92,17 @@ TEST (client, send_single_observing_peer) } } -TEST (client, send_single_many_peers) +TEST (node, send_single_many_peers) { rai::system system (24000, 10); rai::keypair key2; system.wallet (0)->store.insert (rai::test_genesis_key.prv); system.wallet (1)->store.insert (key2.prv); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000)); - ASSERT_EQ (std::numeric_limits ::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); - ASSERT_TRUE (system.clients [0]->ledger.account_balance (key2.pub).is_zero ()); + ASSERT_EQ (std::numeric_limits ::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_TRUE (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ()); auto iterations (0); - while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr const & client_a) {return client_a->ledger.account_balance (key2.pub).is_zero();})) + while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr const & node_a) {return node_a->ledger.account_balance (key2.pub).is_zero();})) { system.service->poll_one (); system.processor.poll_one (); @@ -111,7 +111,7 @@ TEST (client, send_single_many_peers) } } -TEST (client, send_out_of_order) +TEST (node, send_out_of_order) { rai::system system (24000, 2); rai::keypair key2; @@ -126,10 +126,10 @@ TEST (client, send_out_of_order) send2.hashables.destination = key2.pub; send2.hashables.previous = send1.hash (); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send2.hash (), send2.signature); - system.clients [0]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (send2))); - system.clients [0]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (send1))); + system.nodes [0]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (send2))); + system.nodes [0]->processor.process_receive_republish (std::unique_ptr (new rai::send_block (send1))); auto iterations (0); - while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr const & client_a) {return client_a->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits ::max () - 2000;})) + while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr const & node_a) {return node_a->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits ::max () - 2000;})) { system.service->poll_one (); ++iterations; @@ -137,7 +137,7 @@ TEST (client, send_out_of_order) } } -TEST (client, quick_confirm) +TEST (node, quick_confirm) { rai::system system (24000, 1); rai::keypair key; @@ -145,12 +145,12 @@ TEST (client, quick_confirm) rai::send_block send; send.hashables.balance = 0; send.hashables.destination = key.pub; - send.hashables.previous = system.clients [0]->ledger.latest (rai::test_genesis_key.pub); - system.clients [0]->work_create (send); + send.hashables.previous = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub); + system.nodes [0]->work_create (send); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send.hash (), send.signature); - ASSERT_EQ (rai::process_result::progress, system.clients [0]->processor.process_receive (send)); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->processor.process_receive (send)); auto iterations (0); - while (system.clients [0]->ledger.account_balance (key.pub).is_zero ()) + while (system.nodes [0]->ledger.account_balance (key.pub).is_zero ()) { system.processor.poll_one (); system.service->poll_one (); @@ -159,7 +159,7 @@ TEST (client, quick_confirm) } } -TEST (client, auto_bootstrap) +TEST (node, auto_bootstrap) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -173,16 +173,16 @@ TEST (client, auto_bootstrap) system.processor.poll_one (); ++iterations1; ASSERT_LT (iterations1, 200); - } while (system.clients [0]->ledger.account_balance (key2.pub) != 100); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + } while (system.nodes [0]->ledger.account_balance (key2.pub) != 100); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); ASSERT_FALSE (init1.error ()); - client1->network.send_keepalive (system.clients [0]->network.endpoint ()); + client1->network.send_keepalive (system.nodes [0]->network.endpoint ()); client1->start (); ASSERT_FALSE (client1->bootstrap_initiator.warmed_up); ASSERT_FALSE (client1->bootstrap_initiator.in_progress); - ASSERT_FALSE (system.clients [0]->bootstrap_initiator.warmed_up); - ASSERT_FALSE (system.clients [0]->bootstrap_initiator.in_progress); + ASSERT_FALSE (system.nodes [0]->bootstrap_initiator.warmed_up); + ASSERT_FALSE (system.nodes [0]->bootstrap_initiator.in_progress); auto iterations2 (0); do { @@ -190,9 +190,9 @@ TEST (client, auto_bootstrap) system.processor.poll_one (); ++iterations2; ASSERT_LT (iterations2, 200); - } while (!client1->bootstrap_initiator.in_progress || !system.clients [0]->bootstrap_initiator.in_progress); + } while (!client1->bootstrap_initiator.in_progress || !system.nodes [0]->bootstrap_initiator.in_progress); ASSERT_TRUE (client1->bootstrap_initiator.warmed_up); - ASSERT_TRUE (system.clients [0]->bootstrap_initiator.warmed_up); + ASSERT_TRUE (system.nodes [0]->bootstrap_initiator.warmed_up); auto iterations3 (0); do { @@ -208,21 +208,21 @@ TEST (client, auto_bootstrap) system.processor.poll_one (); ++iterations4; ASSERT_LT (iterations4, 200); - } while (client1->bootstrap_initiator.in_progress || system.clients [0]->bootstrap_initiator.in_progress); + } while (client1->bootstrap_initiator.in_progress || system.nodes [0]->bootstrap_initiator.in_progress); client1->stop (); } -TEST (client, auto_bootstrap_reverse) +TEST (node, auto_bootstrap_reverse) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); ASSERT_FALSE (init1.error ()); rai::keypair key2; system.wallet (0)->store.insert (key2.prv); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100)); - system.clients [0]->network.send_keepalive (client1->network.endpoint ()); + system.nodes [0]->network.send_keepalive (client1->network.endpoint ()); client1->start (); auto iterations (0); do @@ -235,7 +235,7 @@ TEST (client, auto_bootstrap_reverse) client1->stop (); } -TEST (client, multi_account_send_atomicness) +TEST (node, multi_account_send_atomicness) { rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -245,10 +245,10 @@ TEST (client, multi_account_send_atomicness) system.wallet (0)->send (key1.pub, std::numeric_limits::max () / 2 + std::numeric_limits::max () / 4); } -TEST (client, receive_gap) +TEST (node, receive_gap) { rai::system system (24000, 1); - auto & client (*system.clients [0]); + auto & client (*system.nodes [0]); ASSERT_EQ (0, client.gap_cache.blocks.size ()); rai::send_block block; rai::confirm_req message; @@ -257,7 +257,7 @@ TEST (client, receive_gap) ASSERT_EQ (1, client.gap_cache.blocks.size ()); } -TEST (client, scaling) +TEST (node, scaling) { rai::system system (24000, 1); auto max (std::numeric_limits ::max ()); @@ -268,7 +268,7 @@ TEST (client, scaling) ASSERT_EQ (up1 - up2, rai::scale_64bit_base10); } -TEST (client, scale_num) +TEST (node, scale_num) { rai::system system (24000, 1); rai::uint128_t num ("60000000000000000000000000000000000000"); @@ -277,25 +277,25 @@ TEST (client, scale_num) ASSERT_EQ (num, up); } -TEST (client, merge_peers) +TEST (node, merge_peers) { rai::system system (24000, 1); std::array endpoints; endpoints.fill (rai::endpoint (boost::asio::ip::address_v6::loopback (), 24000)); endpoints [0] = rai::endpoint (boost::asio::ip::address_v6::loopback (), 24001); - system.clients [0]->network.merge_peers (endpoints); - ASSERT_EQ (0, system.clients [0]->peers.peers.size ()); + system.nodes [0]->network.merge_peers (endpoints); + ASSERT_EQ (0, system.nodes [0]->peers.peers.size ()); } -TEST (client, search_pending) +TEST (node, search_pending) { rai::system system (24000, 1); rai::keypair key2; system.wallet (0)->store.insert (rai::test_genesis_key.prv); - auto balance (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); + auto balance (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000)); auto iterations1 (0); - while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance) + while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance) { system.service->poll_one (); system.processor.poll_one (); @@ -303,9 +303,9 @@ TEST (client, search_pending) ASSERT_LT (iterations1, 200); } system.wallet (0)->store.insert (key2.prv); - system.clients [0]->processor.search_pending (); + system.nodes [0]->processor.search_pending (); auto iterations2 (0); - while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ()) + while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ()) { system.service->poll_one (); system.processor.poll_one (); @@ -314,15 +314,15 @@ TEST (client, search_pending) } } -TEST (client, connect_after_junk) +TEST (node, connect_after_junk) { rai::system system (24000, 1); - rai::client_init init1; - auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); + rai::node_init init1; + auto client1 (std::make_shared (init1, system.service, 24001, system.processor)); uint64_t junk; - client1->network.socket.async_send_to (boost::asio::buffer (&junk, sizeof (junk)), system.clients [0]->network.endpoint (), [] (boost::system::error_code const &, size_t) {}); + client1->network.socket.async_send_to (boost::asio::buffer (&junk, sizeof (junk)), system.nodes [0]->network.endpoint (), [] (boost::system::error_code const &, size_t) {}); auto iterations1 (0); - while (system.clients [0]->network.error_count == 0) + while (system.nodes [0]->network.error_count == 0) { system.service->poll_one (); system.processor.poll_one (); @@ -330,7 +330,7 @@ TEST (client, connect_after_junk) ASSERT_LT (iterations1, 200); } client1->start (); - client1->network.send_keepalive (system.clients [0]->network.endpoint ()); + client1->network.send_keepalive (system.nodes [0]->network.endpoint ()); auto iterations2 (0); while (client1->peers.empty ()) { diff --git a/rai/core_test/rpc.cpp b/rai/core_test/rpc.cpp index f4a13a36..779b0939 100644 --- a/rai/core_test/rpc.cpp +++ b/rai/core_test/rpc.cpp @@ -8,14 +8,14 @@ TEST (rpc, account_create) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; boost::property_tree::ptree request_tree; request_tree.put ("action", "account_create"); std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); std::stringstream ostream; boost::property_tree::write_json (ostream, request_tree); @@ -35,7 +35,7 @@ TEST (rpc, account_balance_exact) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); boost::network::http::server ::request request; @@ -60,7 +60,7 @@ TEST (rpc, account_balance) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); boost::network::http::server ::request request; @@ -86,12 +86,12 @@ TEST (rpc, account_weight_exact) rai::keypair key; rai::system system (24000, 1); rai::frontier frontier; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier)); rai::change_block block (key.pub, frontier.hash, rai::test_genesis_key.prv, rai::test_genesis_key.pub); - system.clients [0]->work_create (block); - ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (block)); + system.nodes [0]->work_create (block); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (block)); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; key.pub.encode_base58check (account); boost::network::http::server ::request request; @@ -117,12 +117,12 @@ TEST (rpc, account_weight) rai::keypair key; rai::system system (24000, 1); rai::frontier frontier; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier)); rai::change_block block (key.pub, frontier.hash, rai::test_genesis_key.prv, rai::test_genesis_key.pub); - system.clients [0]->work_create (block); - ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (block)); + system.nodes [0]->work_create (block); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (block)); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; key.pub.encode_base58check (account); boost::network::http::server ::request request; @@ -147,7 +147,7 @@ TEST (rpc, wallet_contains) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -156,7 +156,7 @@ TEST (rpc, wallet_contains) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "wallet_contains"); request_tree.put ("account", account); @@ -176,7 +176,7 @@ TEST (rpc, wallet_doesnt_contain) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); boost::network::http::server ::request request; @@ -184,7 +184,7 @@ TEST (rpc, wallet_doesnt_contain) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "wallet_contains"); request_tree.put ("account", account); @@ -204,7 +204,7 @@ TEST (rpc, validate_account_number) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -230,7 +230,7 @@ TEST (rpc, validate_account_invalid) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); account [0] ^= 0x1; @@ -257,7 +257,7 @@ TEST (rpc, send_exact) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -268,7 +268,7 @@ TEST (rpc, send_exact) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "send_exact"); request_tree.put ("account", account); @@ -289,7 +289,7 @@ TEST (rpc, send) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -300,7 +300,7 @@ TEST (rpc, send) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "send"); request_tree.put ("account", account); @@ -308,9 +308,9 @@ TEST (rpc, send) std::stringstream ostream; boost::property_tree::write_json (ostream, request_tree); request.body = ostream.str (); - auto balance1 (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); + auto balance1 (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); rpc (request, response); - ASSERT_EQ (balance1 - rai::scale_64bit_base10, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (balance1 - rai::scale_64bit_base10, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); ASSERT_EQ (boost::network::http::server ::response::ok, response.status); boost::property_tree::ptree response_tree; std::stringstream istream (response.content); @@ -323,7 +323,7 @@ TEST (rpc, send_fail) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); rai::keypair key1; @@ -333,7 +333,7 @@ TEST (rpc, send_fail) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "send"); request_tree.put ("account", account); @@ -354,7 +354,7 @@ TEST (rpc, wallet_add) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); rai::keypair key1; std::string key_text; key1.prv.encode_hex (key_text); @@ -364,7 +364,7 @@ TEST (rpc, wallet_add) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "wallet_add"); request_tree.put ("key", key_text); @@ -386,13 +386,13 @@ TEST (rpc, wallet_password_valid) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "password_valid"); std::stringstream ostream; @@ -411,13 +411,13 @@ TEST (rpc, wallet_password_change) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "password_change"); request_tree.put ("password", "test"); @@ -442,13 +442,13 @@ TEST (rpc, wallet_password_enter) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "password_enter"); request_tree.put ("password", ""); @@ -468,13 +468,13 @@ TEST (rpc, representative) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "representative"); std::stringstream ostream; @@ -495,13 +495,13 @@ TEST (rpc, representative_set) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); rai::keypair key; std::string representative_l; @@ -513,14 +513,14 @@ TEST (rpc, representative_set) request.body = ostream.str (); rpc (request, response); ASSERT_EQ (boost::network::http::server ::response::ok, response.status); - ASSERT_EQ (key.pub, system.clients [0]->wallets.items.begin ()->second->store.representative ()); + ASSERT_EQ (key.pub, system.nodes [0]->wallets.items.begin ()->second->store.representative ()); } TEST (rpc, account_list) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -531,7 +531,7 @@ TEST (rpc, account_list) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "account_list"); std::stringstream ostream; @@ -562,7 +562,7 @@ TEST (rpc, wallet_key_valid) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); std::string account; rai::test_genesis_key.pub.encode_base58check (account); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -571,7 +571,7 @@ TEST (rpc, wallet_key_valid) request.method = "POST"; boost::property_tree::ptree request_tree; std::string wallet; - system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet); + system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet); request_tree.put ("wallet", wallet); request_tree.put ("action", "wallet_key_valid"); std::stringstream ostream; @@ -590,7 +590,7 @@ TEST (rpc, wallet_create) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; @@ -607,21 +607,21 @@ TEST (rpc, wallet_create) std::string wallet_text (response_tree.get ("wallet")); rai::uint256_union wallet_id; ASSERT_FALSE (wallet_id.decode_hex (wallet_text)); - ASSERT_NE (system.clients [0]->wallets.items.end (), system.clients [0]->wallets.items.find (wallet_id)); + ASSERT_NE (system.nodes [0]->wallets.items.end (), system.nodes [0]->wallets.items.find (wallet_id)); } TEST (rpc, wallet_export) { rai::system system (24000, 1); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); system.wallet (0)->store.insert (rai::test_genesis_key.prv); boost::network::http::server ::request request; boost::network::http::server ::response response; request.method = "POST"; boost::property_tree::ptree request_tree; request_tree.put ("action", "wallet_export"); - request_tree.put ("wallet", system.clients [0]->wallets.items.begin ()->first.to_string ()); + request_tree.put ("wallet", system.nodes [0]->wallets.items.begin ()->first.to_string ()); std::stringstream ostream; boost::property_tree::write_json (ostream, request_tree); request.body = ostream.str (); @@ -640,9 +640,9 @@ TEST (rpc, wallet_export) TEST (rpc, wallet_destroy) { rai::system system (24000, 1); - auto wallet_id (system.clients [0]->wallets.items.begin ()->first); + auto wallet_id (system.nodes [0]->wallets.items.begin ()->first); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); system.wallet (0)->store.insert (rai::test_genesis_key.prv); boost::network::http::server ::request request; boost::network::http::server ::response response; @@ -658,20 +658,20 @@ TEST (rpc, wallet_destroy) boost::property_tree::ptree response_tree; std::stringstream istream (response.content); boost::property_tree::read_json (istream, response_tree); - ASSERT_EQ (system.clients [0]->wallets.items.end (), system.clients [0]->wallets.items.find (wallet_id)); + ASSERT_EQ (system.nodes [0]->wallets.items.end (), system.nodes [0]->wallets.items.find (wallet_id)); } TEST (rpc, account_move) { rai::system system (24000, 1); - auto wallet_id (system.clients [0]->wallets.items.begin ()->first); + auto wallet_id (system.nodes [0]->wallets.items.begin ()->first); auto pool (boost::make_shared ()); - rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true); + rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true); auto destination (system.wallet (0)); destination->store.insert (rai::test_genesis_key.prv); rai::keypair source_id; rai::keypair key; - auto source (system.clients [0]->wallets.create (source_id.prv)); + auto source (system.nodes [0]->wallets.create (source_id.prv)); source->store.insert (key.prv); boost::network::http::server ::request request; boost::network::http::server ::response response; diff --git a/rai/core_test/wallet.cpp b/rai/core_test/wallet.cpp index 21e5be60..99227e9b 100644 --- a/rai/core_test/wallet.cpp +++ b/rai/core_test/wallet.cpp @@ -92,17 +92,17 @@ TEST (wallet, one_spend) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::frontier frontier1; - system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1); + system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1); rai::keypair key2; ASSERT_FALSE (system.wallet (0)->send (key2.pub, std::numeric_limits ::max ())); rai::frontier frontier2; - system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier2); + system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier2); ASSERT_NE (frontier1, frontier2); - auto block (system.clients [0]->store.block_get (frontier2.hash)); + auto block (system.nodes [0]->store.block_get (frontier2.hash)); ASSERT_NE (nullptr, block); ASSERT_EQ (frontier1.hash, block->previous ()); ASSERT_TRUE (frontier2.balance.is_zero ()); - ASSERT_EQ (0, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (0, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); } TEST (wallet, DISABLED_two_spend) @@ -138,10 +138,10 @@ TEST (wallet, partial_spend) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::frontier frontier1; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); rai::keypair key2; ASSERT_FALSE (system.wallet (0)->send (key2.pub, 500)); - ASSERT_EQ (std::numeric_limits ::max () - 500, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub)); + ASSERT_EQ (std::numeric_limits ::max () - 500, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub)); } TEST (wallet, spend_no_previous) @@ -149,7 +149,7 @@ TEST (wallet, spend_no_previous) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); rai::frontier frontier1; - ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); + ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1)); for (auto i (0); i < 50; ++i) { rai::keypair key; @@ -157,7 +157,7 @@ TEST (wallet, spend_no_previous) } rai::keypair key2; ASSERT_FALSE (system.wallet (0)->send (key2.pub, 500)); - ASSERT_EQ (std::numeric_limits ::max () - 500, system.clients [0]->ledger.account_balance(rai::test_genesis_key.pub)); + ASSERT_EQ (std::numeric_limits ::max () - 500, system.nodes [0]->ledger.account_balance(rai::test_genesis_key.pub)); } TEST (wallet, find_none) diff --git a/rai/core_test/wallets.cpp b/rai/core_test/wallets.cpp index a65e501c..ff1436e6 100644 --- a/rai/core_test/wallets.cpp +++ b/rai/core_test/wallets.cpp @@ -5,7 +5,7 @@ TEST (wallets, open_create) { rai::system system (24000, 1); - rai::wallets wallets (*system.clients [0], boost::filesystem::unique_path ()); + rai::wallets wallets (*system.nodes [0], boost::filesystem::unique_path ()); ASSERT_EQ (0, wallets.items.size ()); rai::uint256_union id; ASSERT_EQ (nullptr, wallets.open (id)); @@ -19,13 +19,13 @@ TEST (wallets, open_existing) rai::uint256_union id; auto path (boost::filesystem::unique_path ()); { - rai::wallets wallets (*system.clients [0], path); + rai::wallets wallets (*system.nodes [0], path); ASSERT_EQ (0, wallets.items.size ()); auto wallet (wallets.create (id)); ASSERT_EQ (wallet, wallets.open (id)); } { - rai::wallets wallets (*system.clients [0], path); + rai::wallets wallets (*system.nodes [0], path); ASSERT_EQ (1, wallets.items.size ()); ASSERT_NE (nullptr, wallets.open (id)); } @@ -37,7 +37,7 @@ TEST (wallets, remove) rai::uint256_union one (1); auto path (boost::filesystem::unique_path ()); { - rai::wallets wallets (*system.clients [0], path); + rai::wallets wallets (*system.nodes [0], path); ASSERT_EQ (0, wallets.items.size ()); auto wallet (wallets.create (one)); ASSERT_EQ (1, wallets.items.size ()); @@ -45,7 +45,7 @@ TEST (wallets, remove) ASSERT_EQ (0, wallets.items.size ()); } { - rai::wallets wallets (*system.clients [0], path); + rai::wallets wallets (*system.nodes [0], path); ASSERT_EQ (0, wallets.items.size ()); } } \ No newline at end of file diff --git a/rai/landing/entry.cpp b/rai/landing/entry.cpp index bb50c82d..a5f05935 100644 --- a/rai/landing/entry.cpp +++ b/rai/landing/entry.cpp @@ -132,7 +132,7 @@ namespace landing config_a.serialize (config_file); } } - void distribute (rai::client & client_a, std::shared_ptr wallet_a, rai::landing::config & config_a, boost::filesystem::path working_path_a) + void distribute (rai::node & node_a, std::shared_ptr wallet_a, rai::landing::config & config_a, boost::filesystem::path working_path_a) { auto now (rai::landing::minutes_since_epoch ()); auto error (false); @@ -152,7 +152,7 @@ namespace landing } } std::cout << "Waiting for next distribution cycle\n"; - client_a.service.add (std::chrono::system_clock::now () + std::chrono::minutes (1), [&client_a, &config_a, working_path_a, wallet_a] () {rai::landing::distribute (client_a, wallet_a, config_a, working_path_a);}); + node_a.service.add (std::chrono::system_clock::now () + std::chrono::minutes (1), [&node_a, &config_a, working_path_a, wallet_a] () {rai::landing::distribute (node_a, wallet_a, config_a, working_path_a);}); } rai::landing::config read_config (bool & config_error, boost::filesystem::path working_path_a) { @@ -181,10 +181,10 @@ int main (int argc, char * const * argv) rai::landing::config config (rai::landing::read_config (config_error, working)); if (!config_error) { - rai::client_init init; + rai::node_init init; auto service (boost::make_shared ()); rai::processor_service processor; - auto client (std::make_shared (init, service, config.peering_port, working, processor)); + auto client (std::make_shared (init, service, config.peering_port, working, processor)); if (!init.error ()) { client->bootstrap_peers = config.bootstrap_peers; diff --git a/rai/core/core.cpp b/rai/node.cpp similarity index 86% rename from rai/core/core.cpp rename to rai/node.cpp index cc1dba39..f7852269 100644 --- a/rai/core/core.cpp +++ b/rai/node.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -214,11 +214,11 @@ std::chrono::seconds constexpr rai::processor::period; std::chrono::seconds constexpr rai::processor::cutoff; std::chrono::milliseconds const rai::confirm_wait = rai_network == rai_networks::rai_test_network ? std::chrono::milliseconds (0) : std::chrono::milliseconds (5000); -rai::network::network (boost::asio::io_service & service_a, uint16_t port, rai::client & client_a) : +rai::network::network (boost::asio::io_service & service_a, uint16_t port, rai::node & node_a) : socket (service_a, boost::asio::ip::udp::endpoint (boost::asio::ip::address_v6::any (), port)), service (service_a), resolver (service_a), -client (client_a), +node (node_a), bad_sender_count (0), on (true), keepalive_count (0), @@ -234,7 +234,7 @@ void rai::network::receive () { if (network_packet_logging ()) { - BOOST_LOG (client.log) << "Receiving packet"; + BOOST_LOG (node.log) << "Receiving packet"; } std::unique_lock lock (socket_mutex); socket.async_receive_from (boost::asio::buffer (buffer.data (), buffer.size ()), remote, @@ -255,7 +255,7 @@ void rai::network::send_keepalive (rai::endpoint const & endpoint_a) { assert (endpoint_a.address ().is_v6 ()); rai::keepalive message; - client.peers.random_fill (message.peers); + node.peers.random_fill (message.peers); std::shared_ptr > bytes (new std::vector ); { rai::vectorstream stream (*bytes); @@ -263,9 +263,9 @@ void rai::network::send_keepalive (rai::endpoint const & endpoint_a) } if (network_keepalive_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Keepalive req sent from %1% to %2%") % endpoint () % endpoint_a); + BOOST_LOG (node.log) << boost::str (boost::format ("Keepalive req sent from %1% to %2%") % endpoint () % endpoint_a); } - auto client_l (client.shared ()); + auto client_l (node.shared ()); send_buffer (bytes->data (), bytes->size (), endpoint_a, [bytes, client_l, endpoint_a] (boost::system::error_code const & ec, size_t) { if (network_logging ()) @@ -281,7 +281,7 @@ void rai::network::send_keepalive (rai::endpoint const & endpoint_a) void rai::network::republish_block (std::unique_ptr block) { auto hash (block->hash ()); - auto list (client.peers.list ()); + auto list (node.peers.list ()); if (!confirm_broadcast (list, block->clone(), 0)) { rai::publish message (std::move (block)); @@ -290,22 +290,22 @@ void rai::network::republish_block (std::unique_ptr block) rai::vectorstream stream (*bytes); message.serialize (stream); } - auto client_l (client.shared ()); + auto node_l (node.shared ()); for (auto i (list.begin ()), n (list.end ()); i != n; ++i) { - if (!client.peers.knows_about (i->endpoint, hash)) + if (!node.peers.knows_about (i->endpoint, hash)) { if (network_publish_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Publish %1% to %2%") % message.block->hash ().to_string () % i->endpoint); + BOOST_LOG (node.log) << boost::str (boost::format ("Publish %1% to %2%") % message.block->hash ().to_string () % i->endpoint); } - send_buffer (bytes->data (), bytes->size (), i->endpoint, [bytes, client_l] (boost::system::error_code const & ec, size_t size) + send_buffer (bytes->data (), bytes->size (), i->endpoint, [bytes, node_l] (boost::system::error_code const & ec, size_t size) { if (network_logging ()) { if (ec) { - BOOST_LOG (client_l->log) << boost::str (boost::format ("Error sending publish: %1%") % ec.message ()); + BOOST_LOG (node_l->log) << boost::str (boost::format ("Error sending publish: %1%") % ec.message ()); } } }); @@ -324,9 +324,9 @@ void rai::network::send_confirm_req (boost::asio::ip::udp::endpoint const & endp } if (network_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Sending confirm req to %1%") % endpoint_a); + BOOST_LOG (node.log) << boost::str (boost::format ("Sending confirm req to %1%") % endpoint_a); } - auto client_l (client.shared ()); + auto client_l (node.shared ()); send_buffer (bytes->data (), bytes->size (), endpoint_a, [bytes, client_l] (boost::system::error_code const & ec, size_t size) { if (network_logging ()) @@ -344,8 +344,8 @@ namespace class network_message_visitor : public rai::message_visitor { public: - network_message_visitor (rai::client & client_a, rai::endpoint const & sender_a) : - client (client_a), + network_message_visitor (rai::node & node_a, rai::endpoint const & sender_a) : + node (node_a), sender (sender_a) { } @@ -353,49 +353,49 @@ public: { if (network_keepalive_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Received keepalive from %1%") % sender); + BOOST_LOG (node.log) << boost::str (boost::format ("Received keepalive from %1%") % sender); } - ++client.network.keepalive_count; - client.processor.contacted (sender); - client.network.merge_peers (message_a.peers); + ++node.network.keepalive_count; + node.processor.contacted (sender); + node.network.merge_peers (message_a.peers); } void publish (rai::publish const & message_a) override { if (network_message_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Received publish req from %1%") % sender); + BOOST_LOG (node.log) << boost::str (boost::format ("Received publish req from %1%") % sender); } - ++client.network.publish_count; - client.processor.contacted (sender); - client.peers.insert (sender, message_a.block->hash ()); - client.processor.process_receive_republish (message_a.block->clone ()); + ++node.network.publish_count; + node.processor.contacted (sender); + node.peers.insert (sender, message_a.block->hash ()); + node.processor.process_receive_republish (message_a.block->clone ()); } void confirm_req (rai::confirm_req const & message_a) override { if (network_message_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Received confirm req %1%") % sender); + BOOST_LOG (node.log) << boost::str (boost::format ("Received confirm req %1%") % sender); } - ++client.network.confirm_req_count; - client.processor.contacted (sender); - client.peers.insert (sender, message_a.block->hash ()); - client.processor.process_receive_republish (message_a.block->clone ()); - if (client.store.block_exists (message_a.block->hash ())) + ++node.network.confirm_req_count; + node.processor.contacted (sender); + node.peers.insert (sender, message_a.block->hash ()); + node.processor.process_receive_republish (message_a.block->clone ()); + if (node.store.block_exists (message_a.block->hash ())) { - client.processor.process_confirmation (*message_a.block, sender); + node.processor.process_confirmation (*message_a.block, sender); } } void confirm_ack (rai::confirm_ack const & message_a) override { if (network_message_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Received Confirm from %1%") % sender); + BOOST_LOG (node.log) << boost::str (boost::format ("Received Confirm from %1%") % sender); } - ++client.network.confirm_ack_count; - client.processor.contacted (sender); - client.peers.insert (sender, message_a.vote.block->hash ()); - client.processor.process_receive_republish (message_a.vote.block->clone ()); - client.vote (message_a.vote); + ++node.network.confirm_ack_count; + node.processor.contacted (sender); + node.peers.insert (sender, message_a.vote.block->hash ()); + node.processor.process_receive_republish (message_a.vote.block->clone ()); + node.vote (message_a.vote); } void bulk_pull (rai::bulk_pull const &) override { @@ -409,7 +409,7 @@ public: { assert (false); } - rai::client & client; + rai::node & node; rai::endpoint sender; }; } @@ -420,7 +420,7 @@ void rai::network::receive_action (boost::system::error_code const & error, size { if (!rai::reserved_address (remote) && remote != endpoint ()) { - network_message_visitor visitor (client, remote); + network_message_visitor visitor (node, remote); rai::message_parser parser (visitor); parser.deserialize_buffer (buffer.data (), size_a); if (parser.error) @@ -436,7 +436,7 @@ void rai::network::receive_action (boost::system::error_code const & error, size { if (network_logging ()) { - BOOST_LOG (client.log) << "Reserved sender"; + BOOST_LOG (node.log) << "Reserved sender"; } ++bad_sender_count; } @@ -446,9 +446,9 @@ void rai::network::receive_action (boost::system::error_code const & error, size { if (network_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Receive error: %1%") % error.message ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Receive error: %1%") % error.message ()); } - client.service.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this] () { receive (); }); + node.service.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this] () { receive (); }); } } @@ -457,7 +457,7 @@ void rai::network::merge_peers (std::array const & peers_a) { for (auto i (peers_a.begin ()), j (peers_a.end ()); i != j; ++i) { - if (!client.peers.not_a_peer (*i) && !client.peers.known_peer (*i)) + if (!node.peers.not_a_peer (*i) && !node.peers.known_peer (*i)) { send_keepalive (*i); } @@ -763,15 +763,15 @@ bool rai::wallet_store::move (rai::wallet_store & other_a, std::vector lock (mutex); auto hash (send_a.hash ()); bool result; - if (client.ledger.store.pending_exists (hash)) + if (node.ledger.store.pending_exists (hash)) { rai::frontier frontier; - auto new_account (client.ledger.store.latest_get (send_a.hashables.destination, frontier)); + auto new_account (node.ledger.store.latest_get (send_a.hashables.destination, frontier)); std::unique_ptr block; if (new_account) { auto open (new rai::open_block); open->hashables.source = hash; open->hashables.representative = representative_a; - client.work_create (*open); + node.work_create (*open); rai::sign_message (prv_a, send_a.hashables.destination, open->hash (), open->signature); block.reset (open); } @@ -799,11 +799,11 @@ bool rai::wallet::receive (rai::send_block const & send_a, rai::private_key cons auto receive (new rai::receive_block); receive->hashables.previous = frontier.hash; receive->hashables.source = hash; - client.work_create (*receive); + node.work_create (*receive); rai::sign_message (prv_a, send_a.hashables.destination, receive->hash (), receive->signature); block.reset (receive); } - client.processor.process_receive_republish (std::move (block)); + node.processor.process_receive_republish (std::move (block)); result = false; } else @@ -825,11 +825,11 @@ bool rai::wallet::send (rai::account const & account_a, rai::uint128_t const & a for (auto i (store.begin ()), j (store.end ()); i != j && !result && !remaining.is_zero (); ++i) { auto account (i->first); - auto balance (client.ledger.account_balance (account)); + auto balance (node.ledger.account_balance (account)); if (!balance.is_zero ()) { rai::frontier frontier; - result = client.ledger.store.latest_get (account, frontier); + result = node.ledger.store.latest_get (account, frontier); assert (!result); auto amount (std::min (remaining, balance)); remaining -= amount; @@ -837,7 +837,7 @@ bool rai::wallet::send (rai::account const & account_a, rai::uint128_t const & a block->hashables.destination = account_a; block->hashables.previous = frontier.hash; block->hashables.balance = balance - amount; - client.work_create (*block); + node.work_create (*block); rai::private_key prv; result = store.fetch (account, prv); assert (!result); @@ -848,23 +848,23 @@ bool rai::wallet::send (rai::account const & account_a, rai::uint128_t const & a } if (!remaining.is_zero ()) { - BOOST_LOG (client.log) << "Wallet contained insufficient coins"; + BOOST_LOG (node.log) << "Wallet contained insufficient coins"; // Destroy the sends because they're signed and we're not going to use them. result = true; blocks.clear (); } else { - BOOST_LOG (client.log) << "Publishing blocks"; + BOOST_LOG (node.log) << "Publishing blocks"; for (auto i (blocks.begin ()), j (blocks.end ()); i != j; ++i) { - client.processor.process_receive_republish (std::move (*i)); + node.processor.process_receive_republish (std::move (*i)); } } } else { - BOOST_LOG (client.log) << "Wallet key is invalid"; + BOOST_LOG (node.log) << "Wallet key is invalid"; } return result; } @@ -891,9 +891,9 @@ bool rai::wallet::import (std::string const & json_a, std::string const & passwo return result; } -rai::wallets::wallets (rai::client & client_a, boost::filesystem::path const & path_a) : +rai::wallets::wallets (rai::node & node_a, boost::filesystem::path const & path_a) : path (path_a), -client (client_a) +node (node_a) { boost::filesystem::create_directories (path_a); boost::filesystem::directory_iterator i (path_a); @@ -907,7 +907,7 @@ client (client_a) { assert (items.find (id) == items.end ()); auto error (false); - auto wallet (std::make_shared (error, client, i->path ())); + auto wallet (std::make_shared (error, node_a, i->path ())); if (!error) { items [id] = wallet; @@ -947,7 +947,7 @@ std::shared_ptr rai::wallets::create (rai::uint256_union const & i bool error; std::string id; id_a.encode_hex (id); - auto wallet (std::make_shared (error, client, path / id)); + auto wallet (std::make_shared (error, node, path / id)); if (!error) { items [id_a] = wallet; @@ -1175,8 +1175,8 @@ void rai::processor_service::stop () condition.notify_all (); } -rai::processor::processor (rai::client & client_a) : -client (client_a) +rai::processor::processor (rai::node & node_a) : +node (node_a) { } @@ -1189,7 +1189,7 @@ void rai::processor::contacted (rai::endpoint const & endpoint_a) endpoint_l = rai::endpoint (boost::asio::ip::address_v6::v4_mapped (endpoint_l.address ().to_v4 ()), endpoint_l.port ()); } assert (endpoint_l.address ().is_v6 ()); - client.peers.insert (endpoint_l); + node.peers.insert (endpoint_l); } void rai::processor::stop () @@ -1201,17 +1201,17 @@ bool rai::operation::operator > (rai::operation const & other_a) const return wakeup > other_a.wakeup; } -rai::client_init::client_init () : +rai::node_init::node_init () : wallet_init (false) { } -bool rai::client_init::error () +bool rai::node_init::error () { return !block_store_init.ok () || wallet_init || ledger_init; } -rai::client::client (rai::client_init & init_a, boost::shared_ptr service_a, uint16_t port_a, boost::filesystem::path const & application_path_a, rai::processor_service & processor_a) : +rai::node::node (rai::node_init & init_a, boost::shared_ptr service_a, uint16_t port_a, boost::filesystem::path const & application_path_a, rai::processor_service & processor_a) : store (init_a.block_store_init, application_path_a / "data"), gap_cache (*this), ledger (init_a.ledger_init, init_a.block_store_init, store), @@ -1324,12 +1324,12 @@ service (processor_a) } } -rai::client::client (rai::client_init & init_a, boost::shared_ptr service_a, uint16_t port_a, rai::processor_service & processor_a) : -client (init_a, service_a, port_a, boost::filesystem::unique_path (), processor_a) +rai::node::node (rai::node_init & init_a, boost::shared_ptr service_a, uint16_t port_a, rai::processor_service & processor_a) : +node (init_a, service_a, port_a, boost::filesystem::unique_path (), processor_a) { } -rai::client::~client () +rai::node::~node () { if (client_lifetime_tracing ()) { @@ -1337,7 +1337,7 @@ rai::client::~client () } } -void rai::client::send_keepalive (rai::endpoint const & endpoint_a) +void rai::node::send_keepalive (rai::endpoint const & endpoint_a) { auto endpoint_l (endpoint_a); if (endpoint_l.address ().is_v4 ()) @@ -1348,7 +1348,7 @@ void rai::client::send_keepalive (rai::endpoint const & endpoint_a) network.send_keepalive (endpoint_l); } -void rai::client::work_create (rai::block & block_a) +void rai::node::work_create (rai::block & block_a) { auto begin (std::chrono::system_clock::now ()); if (work_generation_time ()) @@ -1362,7 +1362,7 @@ void rai::client::work_create (rai::block & block_a) } } -void rai::client::vote (rai::vote const & vote_a) +void rai::node::vote (rai::vote const & vote_a) { for (auto & i: vote_observers) { @@ -1370,8 +1370,8 @@ void rai::client::vote (rai::vote const & vote_a) } } -rai::gap_cache::gap_cache (rai::client & client_a) : -client (client_a) +rai::gap_cache::gap_cache (rai::node & node_a) : +node (node_a) { } @@ -1417,11 +1417,11 @@ void rai::gap_cache::vote (rai::vote const & vote_a) auto changed (existing->votes->vote (vote_a)); if (changed) { - auto winner (client.ledger.winner (*existing->votes)); + auto winner (node.ledger.winner (*existing->votes)); if (winner.first > bootstrap_threshold ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Initiating bootstrap for confirmed gap: %1%") % hash.to_string ()); - client.bootstrap_initiator.bootstrap_any (); + BOOST_LOG (node.log) << boost::str (boost::format ("Initiating bootstrap for confirmed gap: %1%") % hash.to_string ()); + node.bootstrap_initiator.bootstrap_any (); } } } @@ -1429,13 +1429,13 @@ void rai::gap_cache::vote (rai::vote const & vote_a) rai::uint128_t rai::gap_cache::bootstrap_threshold () { - return client.ledger.supply () / 16; + return node.ledger.supply () / 16; } bool rai::network::confirm_broadcast (std::vector & list_a, std::unique_ptr block_a, uint64_t sequence_a) { bool result (false); - for (auto i (client.wallets.items.begin ()), n (client.wallets.items.end ()); i != n; ++i) + for (auto i (node.wallets.items.begin ()), n (node.wallets.items.end ()); i != n; ++i) { auto & wallet (*i->second); if (wallet.store.is_representative ()) @@ -1448,7 +1448,7 @@ bool rai::network::confirm_broadcast (std::vector & list auto hash (block_a->hash ()); for (auto j (list_a.begin ()), m (list_a.end ()); j != m; ++j) { - if (!client.peers.knows_about (j->endpoint, hash)) + if (!node.peers.knows_about (j->endpoint, hash)) { confirm_block (prv, pub, block_a->clone (), sequence_a, j->endpoint); } @@ -1478,16 +1478,16 @@ void rai::network::confirm_block (rai::private_key const & prv, rai::public_key } if (network_publish_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Confirm %1% to %2%") % confirm.vote.block->hash ().to_string () % endpoint_a); + BOOST_LOG (node.log) << boost::str (boost::format ("Confirm %1% to %2%") % confirm.vote.block->hash ().to_string () % endpoint_a); } - auto client_l (client.shared ()); - client.network.send_buffer (bytes->data (), bytes->size (), endpoint_a, [bytes, client_l] (boost::system::error_code const & ec, size_t size_a) + auto node_l (node.shared ()); + node.network.send_buffer (bytes->data (), bytes->size (), endpoint_a, [bytes, node_l] (boost::system::error_code const & ec, size_t size_a) { if (network_logging ()) { if (ec) { - BOOST_LOG (client_l->log) << boost::str (boost::format ("Error broadcasting confirmation: %1%") % ec.message ()); + BOOST_LOG (node_l->log) << boost::str (boost::format ("Error broadcasting confirmation: %1%") % ec.message ()); } } }); @@ -1504,7 +1504,7 @@ void rai::processor::process_receive_republish (std::unique_ptr inc { case rai::process_result::progress: { - client.network.republish_block (std::move (block)); + node.network.republish_block (std::move (block)); break; } default: @@ -1512,14 +1512,14 @@ void rai::processor::process_receive_republish (std::unique_ptr inc break; } } - block = client.gap_cache.get (hash); + block = node.gap_cache.get (hash); } while (block != nullptr); } rai::process_result rai::processor::process_receive (rai::block const & block_a) { - auto result (client.ledger.process (block_a)); + auto result (node.ledger.process (block_a)); switch (result) { case rai::process_result::progress: @@ -1528,7 +1528,7 @@ rai::process_result rai::processor::process_receive (rai::block const & block_a) { std::string block; block_a.serialize_json (block); - BOOST_LOG (client.log) << boost::str (boost::format ("Processing block %1% %2%") % block_a.hash().to_string () % block); + BOOST_LOG (node.log) << boost::str (boost::format ("Processing block %1% %2%") % block_a.hash().to_string () % block); } break; } @@ -1536,27 +1536,27 @@ rai::process_result rai::processor::process_receive (rai::block const & block_a) { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Gap previous for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Gap previous for: %1%") % block_a.hash ().to_string ()); } auto previous (block_a.previous ()); - client.gap_cache.add (block_a, previous); + node.gap_cache.add (block_a, previous); break; } case rai::process_result::gap_source: { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Gap source for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Gap source for: %1%") % block_a.hash ().to_string ()); } auto source (block_a.source ()); - client.gap_cache.add (block_a, source); + node.gap_cache.add (block_a, source); break; } case rai::process_result::old: { if (ledger_duplicate_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Old for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Old for: %1%") % block_a.hash ().to_string ()); } break; } @@ -1564,7 +1564,7 @@ rai::process_result rai::processor::process_receive (rai::block const & block_a) { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Bad signature for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Bad signature for: %1%") % block_a.hash ().to_string ()); } break; } @@ -1572,7 +1572,7 @@ rai::process_result rai::processor::process_receive (rai::block const & block_a) { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Overspend for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Overspend for: %1%") % block_a.hash ().to_string ()); } break; } @@ -1580,7 +1580,7 @@ rai::process_result rai::processor::process_receive (rai::block const & block_a) { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Overreceive for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Overreceive for: %1%") % block_a.hash ().to_string ()); } break; } @@ -1588,7 +1588,7 @@ rai::process_result rai::processor::process_receive (rai::block const & block_a) { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Not receive from spend for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Not receive from spend for: %1%") % block_a.hash ().to_string ()); } break; } @@ -1596,18 +1596,18 @@ rai::process_result rai::processor::process_receive (rai::block const & block_a) { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Fork source for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Fork source for: %1%") % block_a.hash ().to_string ()); } - client.conflicts.start (*client.ledger.successor (block_a.root ()), false); + node.conflicts.start (*node.ledger.successor (block_a.root ()), false); break; } case rai::process_result::fork_previous: { if (ledger_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Fork previous for: %1%") % block_a.hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Fork previous for: %1%") % block_a.hash ().to_string ()); } - client.conflicts.start (*client.ledger.successor (block_a.root ()), false); + node.conflicts.start (*node.ledger.successor (block_a.root ()), false); break; } } @@ -1683,16 +1683,16 @@ size_t rai::processor_service::size () rai::system::system (uint16_t port_a, size_t count_a) : service (new boost::asio::io_service) { - clients.reserve (count_a); + nodes.reserve (count_a); for (size_t i (0); i < count_a; ++i) { - rai::client_init init; - auto client (std::make_shared (init, service, port_a + i, processor)); + rai::node_init init; + auto node (std::make_shared (init, service, port_a + i, processor)); assert (!init.error ()); - client->start (); - clients.push_back (client); + node->start (); + nodes.push_back (node); } - for (auto i (clients.begin ()), j (clients.begin () + 1), n (clients.end ()); j != n; ++i, ++j) + for (auto i (nodes.begin ()), j (nodes.begin () + 1), n (nodes.end ()); j != n; ++i, ++j) { auto starting1 ((*i)->peers.size ()); auto new1 (starting1); @@ -1709,7 +1709,7 @@ service (new boost::asio::io_service) rai::system::~system () { - for (auto & i: clients) + for (auto & i: nodes) { i->stop (); } @@ -1717,30 +1717,30 @@ rai::system::~system () std::shared_ptr rai::system::wallet (size_t index_a) { - assert (clients.size () > index_a); - assert (clients [index_a]->wallets.items.size () == 1); - return clients [index_a]->wallets.items.begin ()->second; + assert (nodes.size () > index_a); + assert (nodes [index_a]->wallets.items.size () == 1); + return nodes [index_a]->wallets.items.begin ()->second; } void rai::processor::process_confirmation (rai::block const & block_a, rai::endpoint const & sender) { - auto client_l (client.shared ()); - for (auto i (client.wallets.items.begin ()), n (client.wallets.items.end ()); i != n; ++i) + auto node_l (node.shared ()); + for (auto i (node.wallets.items.begin ()), n (node.wallets.items.end ()); i != n; ++i) { if (i->second->store.is_representative ()) { auto representative (i->second->store.representative ()); - auto weight (client.ledger.weight (representative)); + auto weight (node.ledger.weight (representative)); if (!weight.is_zero ()) { if (network_message_logging ()) { - BOOST_LOG (client.log) << boost::str (boost::format ("Sending confirm ack to: %1%") % sender); + BOOST_LOG (node.log) << boost::str (boost::format ("Sending confirm ack to: %1%") % sender); } rai::private_key prv; auto error (i->second->store.fetch (representative, prv)); assert (!error); - client.network.confirm_block (prv, representative, block_a.clone (), 0, sender); + node.network.confirm_block (prv, representative, block_a.clone (), 0, sender); } } } @@ -1846,9 +1846,9 @@ void rai::confirm_req::serialize (rai::stream & stream_a) block->serialize (stream_a); } -rai::rpc::rpc (boost::shared_ptr service_a, boost::shared_ptr pool_a, boost::asio::ip::address_v6 const & address_a, uint16_t port_a, rai::client & client_a, bool enable_control_a) : +rai::rpc::rpc (boost::shared_ptr service_a, boost::shared_ptr pool_a, boost::asio::ip::address_v6 const & address_a, uint16_t port_a, rai::node & node_a, bool enable_control_a) : server (decltype (server)::options (*this).address (address_a.to_string ()).port (std::to_string (port_a)).io_service (service_a).thread_pool (pool_a)), -client (client_a), +node (node_a), enable_control (enable_control_a) { } @@ -1887,7 +1887,7 @@ void rai::rpc::operator () (boost::network::http::server ::request con std::string action (request_l.get ("action")); if (log_rpc ()) { - BOOST_LOG (client.log) << request.body; + BOOST_LOG (node.log) << request.body; } if (action == "account_balance_exact") { @@ -1896,7 +1896,7 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (account.decode_base58check (account_text)); if (!error) { - auto balance (client.ledger.account_balance (account)); + auto balance (node.ledger.account_balance (account)); boost::property_tree::ptree response_l; response_l.put ("balance", balance.convert_to ()); set_response (response, response_l); @@ -1914,7 +1914,7 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (account.decode_base58check (account_text)); if (!error) { - auto balance (rai::scale_down (client.ledger.account_balance (account))); + auto balance (rai::scale_down (node.ledger.account_balance (account))); boost::property_tree::ptree response_l; response_l.put ("balance", std::to_string (balance)); set_response (response, response_l); @@ -1932,7 +1932,7 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (account.decode_base58check (account_text)); if (!error) { - auto balance (client.ledger.weight (account)); + auto balance (node.ledger.weight (account)); boost::property_tree::ptree response_l; response_l.put ("weight", balance.convert_to ()); set_response (response, response_l); @@ -1950,7 +1950,7 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (account.decode_base58check (account_text)); if (!error) { - auto balance (rai::scale_down (client.ledger.weight (account))); + auto balance (rai::scale_down (node.ledger.weight (account))); boost::property_tree::ptree response_l; response_l.put ("weight", std::to_string (balance)); set_response (response, response_l); @@ -1970,8 +1970,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { rai::keypair new_key; existing->second->store.insert (new_key.prv); @@ -2011,8 +2011,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { auto exists (existing->second->store.find (account) != existing->second->store.end ()); boost::property_tree::ptree response_l; @@ -2044,8 +2044,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { boost::property_tree::ptree response_l; boost::property_tree::ptree accounts; @@ -2086,8 +2086,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { existing->second->store.insert (key); rai::public_key pub; @@ -2131,8 +2131,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { auto valid (existing->second->store.valid_password ()); boost::property_tree::ptree response_l; @@ -2175,8 +2175,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { std::string account_text (request_l.get ("account")); rai::uint256_union account; @@ -2232,8 +2232,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { std::string account_text (request_l.get ("account")); rai::uint256_union account; @@ -2287,8 +2287,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { boost::property_tree::ptree response_l; response_l.put ("valid", existing->second->store.valid_password () ? "1" : "0"); @@ -2313,8 +2313,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { boost::property_tree::ptree response_l; std::string password_text (request_l.get ("password")); @@ -2341,8 +2341,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { boost::property_tree::ptree response_l; std::string password_text (request_l.get ("password")); @@ -2369,8 +2369,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { boost::property_tree::ptree response_l; std::string representative; @@ -2397,8 +2397,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { std::string representative_text (request_l.get ("representative")); rai::account representative; @@ -2422,7 +2422,7 @@ void rai::rpc::operator () (boost::network::http::server ::request con else if (action == "wallet_create") { rai::keypair wallet_id; - auto wallet (client.wallets.create (wallet_id.prv)); + auto wallet (node.wallets.create (wallet_id.prv)); boost::property_tree::ptree response_l; response_l.put ("wallet", wallet_id.prv.to_string ()); set_response (response, response_l); @@ -2434,8 +2434,8 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { std::string json; existing->second->store.serialize_json (json); @@ -2462,10 +2462,10 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { - client.wallets.destroy (wallet); + node.wallets.destroy (wallet); boost::property_tree::ptree response_l; set_response (response, response_l); } @@ -2490,16 +2490,16 @@ void rai::rpc::operator () (boost::network::http::server ::request con auto error (wallet.decode_hex (wallet_text)); if (!error) { - auto existing (client.wallets.items.find (wallet)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (wallet)); + if (existing != node.wallets.items.end ()) { auto wallet (existing->second); rai::uint256_union source; auto error (source.decode_hex (source_text)); if (!error) { - auto existing (client.wallets.items.find (source)); - if (existing != client.wallets.items.end ()) + auto existing (node.wallets.items.find (source)); + if (existing != node.wallets.items.end ()) { auto source (existing->second); std::vector accounts; @@ -2742,14 +2742,14 @@ void rai::bulk_push::visit (rai::message_visitor & visitor_a) const visitor_a.bulk_push (*this); } -void rai::client::start () +void rai::node::start () { network.receive (); processor.ongoing_keepalive (); bootstrap.start (); } -void rai::client::stop () +void rai::node::stop () { BOOST_LOG (log) << "Client stopping"; network.stop (); @@ -2759,24 +2759,24 @@ void rai::client::stop () void rai::processor::bootstrap (boost::asio::ip::tcp::endpoint const & endpoint_a, std::function const & completion_action_a) { - auto processor (std::make_shared (client.shared (), completion_action_a)); + auto processor (std::make_shared (node.shared (), completion_action_a)); processor->run (endpoint_a); } void rai::processor::connect_bootstrap (std::vector const & peers_a) { - auto client_l (client.shared ()); - client.service.add (std::chrono::system_clock::now (), [client_l, peers_a] () + auto node_l (node.shared ()); + node.service.add (std::chrono::system_clock::now (), [node_l, peers_a] () { for (auto i (peers_a.begin ()), n (peers_a.end ()); i != n; ++i) { - client_l->network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (*i, std::to_string (rai::network::node_port)), [client_l] (boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) + node_l->network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (*i, std::to_string (rai::network::node_port)), [node_l] (boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) { if (!ec) { for (auto i (i_a), n (boost::asio::ip::udp::resolver::iterator {}); i != n; ++i) { - client_l->send_keepalive (i->endpoint ()); + node_l->send_keepalive (i->endpoint ()); } } }); @@ -2786,32 +2786,32 @@ void rai::processor::connect_bootstrap (std::vector const & peers_ void rai::processor::search_pending () { - auto client_l (client.shared ()); - client.service.add (std::chrono::system_clock::now (), [client_l] () + auto node_l (node.shared ()); + node.service.add (std::chrono::system_clock::now (), [node_l] () { std::unordered_set wallet; - for (auto i (client_l->wallets.items.begin ()), n (client_l->wallets.items.end ()); i != n; ++i) + for (auto i (node_l->wallets.items.begin ()), n (node_l->wallets.items.end ()); i != n; ++i) { for (auto j (i->second->store.begin ()), m (i->second->store.end ()); j != m; ++j) { wallet.insert (j->first); } } - for (auto i (client_l->store.pending_begin ()), n (client_l->store.pending_end ()); i != n; ++i) + for (auto i (node_l->store.pending_begin ()), n (node_l->store.pending_end ()); i != n; ++i) { if (wallet.find (i->second.destination) != wallet.end ()) { - auto block (client_l->store.block_get (i->first)); + auto block (node_l->store.block_get (i->first)); assert (block != nullptr); assert (dynamic_cast (block.get ()) != nullptr); - client_l->conflicts.start (*block, true); + node_l->conflicts.start (*block, true); } } }); } -rai::bootstrap_initiator::bootstrap_initiator (rai::client & client_a) : -client (client_a), +rai::bootstrap_initiator::bootstrap_initiator (rai::node & node_a) : +node (node_a), in_progress (false), warmed_up (false) { @@ -2839,7 +2839,7 @@ void rai::bootstrap_initiator::bootstrap (rai::endpoint const & endpoint_a) void rai::bootstrap_initiator::bootstrap_any () { - auto list (client.peers.list ()); + auto list (node.peers.list ()); if (!list.empty ()) { bootstrap (list [0].endpoint); @@ -2848,18 +2848,18 @@ void rai::bootstrap_initiator::bootstrap_any () void rai::bootstrap_initiator::initiate (rai::endpoint const & endpoint_a) { - client.processor.bootstrap (rai::tcp_endpoint (endpoint_a.address (), endpoint_a.port ()), [this] () + node.processor.bootstrap (rai::tcp_endpoint (endpoint_a.address (), endpoint_a.port ()), [this] () { std::lock_guard lock (mutex); in_progress = false; }); } -rai::bootstrap_listener::bootstrap_listener (boost::asio::io_service & service_a, uint16_t port_a, rai::client & client_a) : +rai::bootstrap_listener::bootstrap_listener (boost::asio::io_service & service_a, uint16_t port_a, rai::node & node_a) : acceptor (service_a), local (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v6::any (), port_a)), service (service_a), -client (client_a) +node (node_a) { } @@ -2892,18 +2892,18 @@ void rai::bootstrap_listener::accept_action (boost::system::error_code const & e if (!ec) { accept_connection (); - auto connection (std::make_shared (socket_a, client.shared ())); + auto connection (std::make_shared (socket_a, node.shared ())); connection->receive (); } else { - BOOST_LOG (client.log) << boost::str (boost::format ("Error while accepting bootstrap connections: %1%") % ec.message ()); + BOOST_LOG (node.log) << boost::str (boost::format ("Error while accepting bootstrap connections: %1%") % ec.message ()); } } -rai::bootstrap_server::bootstrap_server (std::shared_ptr socket_a, std::shared_ptr client_a) : +rai::bootstrap_server::bootstrap_server (std::shared_ptr socket_a, std::shared_ptr node_a) : socket (socket_a), -client (client_a) +node (node_a) { } @@ -2958,7 +2958,7 @@ void rai::bootstrap_server::receive_header_action (boost::system::error_code con { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Received invalid type from bootstrap connection %1%") % static_cast (type)); + BOOST_LOG (node->log) << boost::str (boost::format ("Received invalid type from bootstrap connection %1%") % static_cast (type)); } break; } @@ -2969,7 +2969,7 @@ void rai::bootstrap_server::receive_header_action (boost::system::error_code con { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Error while receiving type %1%") % ec.message ()); + BOOST_LOG (node->log) << boost::str (boost::format ("Error while receiving type %1%") % ec.message ()); } } } @@ -2985,7 +2985,7 @@ void rai::bootstrap_server::receive_bulk_pull_action (boost::system::error_code { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Received bulk pull for %1% down to %2%") % request->start.to_string () % request->end.to_string ()); + BOOST_LOG (node->log) << boost::str (boost::format ("Received bulk pull for %1% down to %2%") % request->start.to_string () % request->end.to_string ()); } add_request (std::unique_ptr (request.release ())); receive (); @@ -3004,7 +3004,7 @@ void rai::bootstrap_server::receive_frontier_req_action (boost::system::error_co { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Received frontier request for %1% with age %2%") % request->start.to_string () % request->age); + BOOST_LOG (node->log) << boost::str (boost::format ("Received frontier request for %1% with age %2%") % request->start.to_string () % request->age); } add_request (std::unique_ptr (request.release ())); receive (); @@ -3014,7 +3014,7 @@ void rai::bootstrap_server::receive_frontier_req_action (boost::system::error_co { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Error sending receiving frontier request %1%") % ec.message ()); + BOOST_LOG (node->log) << boost::str (boost::format ("Error sending receiving frontier request %1%") % ec.message ()); } } } @@ -3094,11 +3094,11 @@ void rai::bootstrap_server::run_next () void rai::bulk_pull_server::set_current_end () { assert (request != nullptr); - auto end_exists (request->end.is_zero () || connection->client->store.block_exists (request->end)); + auto end_exists (request->end.is_zero () || connection->node->store.block_exists (request->end)); if (end_exists) { rai::frontier frontier; - auto no_address (connection->client->store.latest_get (request->start, frontier)); + auto no_address (connection->node->store.latest_get (request->start, frontier)); if (no_address) { current = request->end; @@ -3107,7 +3107,7 @@ void rai::bulk_pull_server::set_current_end () { if (!request->end.is_zero ()) { - auto account (connection->client->ledger.account (request->end)); + auto account (connection->node->ledger.account (request->end)); if (account == request->start) { current = frontier.hash; @@ -3142,7 +3142,7 @@ void rai::bulk_pull_server::send_next () auto this_l (shared_from_this ()); if (network_logging ()) { - BOOST_LOG (connection->client->log) << boost::str (boost::format ("Sending block: %1%") % block->hash ().to_string ()); + BOOST_LOG (connection->node->log) << boost::str (boost::format ("Sending block: %1%") % block->hash ().to_string ()); } async_write (*connection->socket, boost::asio::buffer (send_buffer.data (), send_buffer.size ()), [this_l] (boost::system::error_code const & ec, size_t size_a) { @@ -3160,7 +3160,7 @@ std::unique_ptr rai::bulk_pull_server::get_next () std::unique_ptr result; if (current != request->end) { - result = connection->client->store.block_get (current); + result = connection->node->store.block_get (current); assert (result != nullptr); auto previous (result->previous ()); if (!previous.is_zero ()) @@ -3190,7 +3190,7 @@ void rai::bulk_pull_server::send_finished () auto this_l (shared_from_this ()); if (network_logging ()) { - BOOST_LOG (connection->client->log) << "Bulk sending finished"; + BOOST_LOG (connection->node->log) << "Bulk sending finished"; } async_write (*connection->socket, boost::asio::buffer (send_buffer.data (), 1), [this_l] (boost::system::error_code const & ec, size_t size_a) { @@ -3213,9 +3213,9 @@ rai::account_iterator rai::block_store::latest_begin (rai::account const & accou return result; } -rai::bootstrap_client::bootstrap_client (std::shared_ptr client_a, std::function const & completion_action_a) : -client (client_a), -socket (client_a->network.service), +rai::bootstrap_client::bootstrap_client (std::shared_ptr node_a, std::function const & completion_action_a) : +node (node_a), +socket (node_a->network.service), completion_action (completion_action_a) { } @@ -3224,7 +3224,7 @@ rai::bootstrap_client::~bootstrap_client () { if (network_logging ()) { - BOOST_LOG (client->log) << "Exiting bootstrap processor"; + BOOST_LOG (node->log) << "Exiting bootstrap processor"; } completion_action (); } @@ -3233,7 +3233,7 @@ void rai::bootstrap_client::run (boost::asio::ip::tcp::endpoint const & endpoint { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Initiating bootstrap connection to %1%") % endpoint_a); + BOOST_LOG (node->log) << boost::str (boost::format ("Initiating bootstrap connection to %1%") % endpoint_a); } auto this_l (shared_from_this ()); socket.async_connect (endpoint_a, [this_l] (boost::system::error_code const & ec) @@ -3265,7 +3265,7 @@ void rai::bootstrap_client::connect_action (boost::system::error_code const & ec { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Error initiating bootstrap connection %1%") % ec.message ()); + BOOST_LOG (node->log) << boost::str (boost::format ("Error initiating bootstrap connection %1%") % ec.message ()); } } } @@ -3282,7 +3282,7 @@ void rai::bootstrap_client::sent_request (boost::system::error_code const & ec, { if (network_logging ()) { - BOOST_LOG (client->log) << boost::str (boost::format ("Error while sending bootstrap request %1%") % ec.message ()); + BOOST_LOG (node->log) << boost::str (boost::format ("Error while sending bootstrap request %1%") % ec.message ()); } } } @@ -3309,7 +3309,7 @@ void rai::bulk_pull_client::request () } else { - BOOST_LOG (this_l->connection->connection->client->log) << boost::str (boost::format ("Error sending bulk pull request %1%") % ec.message ()); + BOOST_LOG (this_l->connection->connection->node->log) << boost::str (boost::format ("Error sending bulk pull request %1%") % ec.message ()); } }); } @@ -3331,7 +3331,7 @@ void rai::bulk_pull_client::receive_block () } else { - BOOST_LOG (this_l->connection->connection->client->log) << boost::str (boost::format ("Error receiving block type %1%") % ec.message ()); + BOOST_LOG (this_l->connection->connection->node->log) << boost::str (boost::format ("Error receiving block type %1%") % ec.message ()); } }); } @@ -3381,7 +3381,7 @@ void rai::bulk_pull_client::received_type () } default: { - BOOST_LOG (connection->connection->client->log) << "Unknown type received as block type"; + BOOST_LOG (connection->connection->node->log) << "Unknown type received as block type"; break; } } @@ -3523,26 +3523,26 @@ void rai::bulk_pull_client::process_end () { rai::pull_synchronization synchronization ([this] (rai::block const & block_a) { - auto process_result (connection->connection->client->processor.process_receive (block_a)); + auto process_result (connection->connection->node->processor.process_receive (block_a)); switch (process_result) { case rai::process_result::progress: case rai::process_result::old: break; default: - BOOST_LOG (connection->connection->client->log) << "Error inserting block"; + BOOST_LOG (connection->connection->node->log) << "Error inserting block"; break; } - connection->connection->client->store.unchecked_del (block_a.hash ()); - }, connection->connection->client->store); - while (connection->connection->client->store.unchecked_begin () != connection->connection->client->store.unchecked_end ()) + connection->connection->node->store.unchecked_del (block_a.hash ()); + }, connection->connection->node->store); + while (connection->connection->node->store.unchecked_begin () != connection->connection->node->store.unchecked_end ()) { - auto error (synchronization.synchronize (connection->connection->client->store.unchecked_begin ()->first)); + auto error (synchronization.synchronize (connection->connection->node->store.unchecked_begin ()->first)); if (error) { while (!synchronization.blocks.empty ()) { - connection->connection->client->store.unchecked_del (synchronization.blocks.top ()); + connection->connection->node->store.unchecked_del (synchronization.blocks.top ()); synchronization.blocks.pop (); } } @@ -3562,14 +3562,14 @@ void rai::bulk_pull_client::received_block (boost::system::error_code const & ec { std::string block_l; block->serialize_json (block_l); - BOOST_LOG (connection->connection->client->log) << boost::str (boost::format ("Pulled block %1% %2%") % hash.to_string () % block_l); + BOOST_LOG (connection->connection->node->log) << boost::str (boost::format ("Pulled block %1% %2%") % hash.to_string () % block_l); } - connection->connection->client->store.unchecked_put (hash, *block); + connection->connection->node->store.unchecked_put (hash, *block); receive_block (); } else { - BOOST_LOG (connection->connection->client->log) << "Error deserializing block received from pull request"; + BOOST_LOG (connection->connection->node->log) << "Error deserializing block received from pull request"; } } } @@ -3588,7 +3588,7 @@ rai::bootstrap_server::~bootstrap_server () { if (network_logging ()) { - BOOST_LOG (client->log) << "Exiting bootstrap connection"; + BOOST_LOG (node->log) << "Exiting bootstrap connection"; } } @@ -3618,13 +3618,13 @@ void rai::peer_container::random_fill (std::array & target_a) void rai::processor::ongoing_keepalive () { - connect_bootstrap (client.bootstrap_peers); - auto peers (client.peers.purge_list (std::chrono::system_clock::now () - cutoff)); + connect_bootstrap (node.bootstrap_peers); + auto peers (node.peers.purge_list (std::chrono::system_clock::now () - cutoff)); for (auto i (peers.begin ()), j (peers.end ()); i != j && std::chrono::system_clock::now () - i->last_attempt > period; ++i) { - client.network.send_keepalive (i->endpoint); + node.network.send_keepalive (i->endpoint); } - client.service.add (std::chrono::system_clock::now () + period, [this] () { ongoing_keepalive ();}); + node.service.add (std::chrono::system_clock::now () + period, [this] () { ongoing_keepalive ();}); } std::vector rai::peer_container::purge_list (std::chrono::system_clock::time_point const & cutoff) @@ -3779,7 +3779,7 @@ void rai::network::send_buffer (uint8_t const * data_a, size_t size_a, rai::endp { if (network_packet_logging ()) { - BOOST_LOG (client.log) << "Sending packet"; + BOOST_LOG (node.log) << "Sending packet"; } socket.async_send_to (boost::asio::buffer (data_a, size_a), endpoint_a, [this] (boost::system::error_code const & ec, size_t size_a) { @@ -3792,7 +3792,7 @@ void rai::network::send_complete (boost::system::error_code const & ec, size_t s { if (network_packet_logging ()) { - BOOST_LOG (client.log) << "Packet send complete"; + BOOST_LOG (node.log) << "Packet send complete"; } std::tuple > self; { @@ -3807,7 +3807,7 @@ void rai::network::send_complete (boost::system::error_code const & ec, size_t s { if (network_packet_logging ()) { - BOOST_LOG (client.log) << "Sending packet"; + BOOST_LOG (node.log) << "Sending packet"; } } socket.async_send_to (boost::asio::buffer (std::get <0> (front), std::get <1> (front)), std::get <2> (front), [this] (boost::system::error_code const & ec, size_t size_a) @@ -3843,7 +3843,7 @@ void rai::bulk_push_server::receive () } else { - BOOST_LOG (this_l->connection->client->log) << boost::str (boost::format ("Error receiving block type %1%") % ec.message ()); + BOOST_LOG (this_l->connection->node->log) << boost::str (boost::format ("Error receiving block type %1%") % ec.message ()); } }); } @@ -3893,7 +3893,7 @@ void rai::bulk_push_server::received_type () } default: { - BOOST_LOG (connection->client->log) << "Unknown type received as block type"; + BOOST_LOG (connection->node->log) << "Unknown type received as block type"; break; } } @@ -3907,12 +3907,12 @@ void rai::bulk_push_server::received_block (boost::system::error_code const & ec auto block (rai::deserialize_block (stream)); if (block != nullptr) { - connection->client->processor.process_receive_republish (std::move (block)); + connection->node->processor.process_receive_republish (std::move (block)); receive (); } else { - BOOST_LOG (connection->client->log) << "Error deserializing block received from pull request"; + BOOST_LOG (connection->node->log) << "Error deserializing block received from pull request"; } } } @@ -3926,7 +3926,7 @@ request (std::move (request_a)) rai::frontier_req_server::frontier_req_server (std::shared_ptr const & connection_a, std::unique_ptr request_a) : connection (connection_a), -iterator (connection_a->client->store.latest_begin (request_a->start)), +iterator (connection_a->node->store.latest_begin (request_a->start)), request (std::move (request_a)) { skip_old (); @@ -3936,8 +3936,8 @@ void rai::frontier_req_server::skip_old () { if (request->age != std::numeric_limitsage)>::max ()) { - auto now (connection->client->store.now ()); - while (iterator != connection->client->ledger.store.latest_end () && (now - iterator->second.time) >= request->age) + auto now (connection->node->store.now ()); + while (iterator != connection->node->ledger.store.latest_end () && (now - iterator->second.time) >= request->age) { ++iterator; } @@ -3958,7 +3958,7 @@ void rai::frontier_req_server::send_next () auto this_l (shared_from_this ()); if (network_logging ()) { - BOOST_LOG (connection->client->log) << boost::str (boost::format ("Sending frontier for %1% %2%") % pair.first.to_string () % pair.second.to_string ()); + BOOST_LOG (connection->node->log) << boost::str (boost::format ("Sending frontier for %1% %2%") % pair.first.to_string () % pair.second.to_string ()); } async_write (*connection->socket, boost::asio::buffer (send_buffer.data (), send_buffer.size ()), [this_l] (boost::system::error_code const & ec, size_t size_a) { @@ -3983,7 +3983,7 @@ void rai::frontier_req_server::send_finished () auto this_l (shared_from_this ()); if (network_logging ()) { - BOOST_LOG (connection->client->log) << "Frontier sending finished"; + BOOST_LOG (connection->node->log) << "Frontier sending finished"; } async_write (*connection->socket, boost::asio::buffer (send_buffer.data (), send_buffer.size ()), [this_l] (boost::system::error_code const & ec, size_t size_a) { @@ -4001,7 +4001,7 @@ void rai::frontier_req_server::no_block_sent (boost::system::error_code const & { if (network_logging ()) { - BOOST_LOG (connection->client->log) << boost::str (boost::format ("Error sending frontier finish %1%") % ec.message ()); + BOOST_LOG (connection->node->log) << boost::str (boost::format ("Error sending frontier finish %1%") % ec.message ()); } } } @@ -4016,7 +4016,7 @@ void rai::frontier_req_server::sent_action (boost::system::error_code const & ec { if (network_logging ()) { - BOOST_LOG (connection->client->log) << boost::str (boost::format ("Error sending frontier pair %1%") % ec.message ()); + BOOST_LOG (connection->node->log) << boost::str (boost::format ("Error sending frontier pair %1%") % ec.message ()); } } } @@ -4024,7 +4024,7 @@ void rai::frontier_req_server::sent_action (boost::system::error_code const & ec std::pair rai::frontier_req_server::get_next () { std::pair result (0, 0); - if (iterator != connection->client->ledger.store.latest_end ()) + if (iterator != connection->node->ledger.store.latest_end ()) { result.first = iterator->first; result.second = iterator->second.hash; @@ -4088,14 +4088,14 @@ rai::bulk_pull_client::~bulk_pull_client () { if (network_logging ()) { - BOOST_LOG (connection->connection->client->log) << "Exiting bulk pull client"; + BOOST_LOG (connection->connection->node->log) << "Exiting bulk pull client"; } } rai::frontier_req_client::frontier_req_client (std::shared_ptr const & connection_a) : connection (connection_a), -current (connection->client->store.latest_begin ()), -end (connection->client->store.latest_end ()) +current (connection->node->store.latest_begin ()), +end (connection->node->store.latest_end ()) { } @@ -4103,7 +4103,7 @@ rai::frontier_req_client::~frontier_req_client () { if (network_logging ()) { - BOOST_LOG (connection->client->log) << "Exiting frontier_req initiator"; + BOOST_LOG (connection->node->log) << "Exiting frontier_req initiator"; } } @@ -4158,7 +4158,7 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons { // In sync } - else if (connection->client->store.block_exists (latest)) + else if (connection->node->store.block_exists (latest)) { // We know about a block they don't. pushes [account] = latest; @@ -4197,7 +4197,7 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons { if (network_logging ()) { - BOOST_LOG (connection->client->log) << boost::str (boost::format ("Error while receiving frontier %1%") % ec.message ()); + BOOST_LOG (connection->node->log) << boost::str (boost::format ("Error while receiving frontier %1%") % ec.message ()); } } } @@ -4220,7 +4220,7 @@ end (connection->pushes.end ()), synchronization ([this] (rai::block const & block_a) { push_block (block_a); -}, connection_a->connection->client->store) +}, connection_a->connection->node->store) { } @@ -4228,7 +4228,7 @@ rai::bulk_push_client::~bulk_push_client () { if (network_logging ()) { - BOOST_LOG (connection->connection->client->log) << "Exiting bulk push client"; + BOOST_LOG (connection->connection->node->log) << "Exiting bulk push client"; } } @@ -4249,7 +4249,7 @@ void rai::bulk_push_client::start () } else { - BOOST_LOG (this_l->connection->connection->client->log) << boost::str (boost::format ("Unable to send bulk_push request %1%") % ec.message ()); + BOOST_LOG (this_l->connection->connection->node->log) << boost::str (boost::format ("Unable to send bulk_push request %1%") % ec.message ()); } }); } @@ -4260,7 +4260,7 @@ void rai::bulk_push_client::push () { auto hash (current->first); rai::frontier frontier; - auto error (connection->connection->client->store.latest_get (hash, frontier)); + auto error (connection->connection->node->store.latest_get (hash, frontier)); assert (!error); ++current; assert (synchronization.blocks.empty ()); @@ -4279,7 +4279,7 @@ void rai::bulk_push_client::send_finished () buffer->push_back (static_cast (rai::block_type::not_a_block)); if (network_logging ()) { - BOOST_LOG (connection->connection->client->log) << "Bulk push finished"; + BOOST_LOG (connection->connection->node->log) << "Bulk push finished"; } auto this_l (shared_from_this ()); async_write (connection->connection->socket, boost::asio::buffer (buffer->data (), 1), [this_l] (boost::system::error_code const & ec, size_t size_a) @@ -4311,7 +4311,7 @@ void rai::bulk_push_client::push_block (rai::block const & block_a) } else { - BOOST_LOG (this_l->connection->connection->client->log) << boost::str (boost::format ("Error sending block during bulk push %1%") % ec.message ()); + BOOST_LOG (this_l->connection->connection->node->log) << boost::str (boost::format ("Error sending block during bulk push %1%") % ec.message ()); } }); } @@ -4328,7 +4328,7 @@ bool rai::peer_container::known_peer (rai::endpoint const & endpoint_a) return existing != peers.end () && existing->last_contact > std::chrono::system_clock::now () - rai::processor::cutoff; } -std::shared_ptr rai::client::shared () +std::shared_ptr rai::node::shared () { return shared_from_this (); } @@ -4338,10 +4338,10 @@ namespace class traffic_generator : public std::enable_shared_from_this { public: - traffic_generator (uint32_t count_a, uint32_t wait_a, std::shared_ptr client_a, rai::system & system_a) : + traffic_generator (uint32_t count_a, uint32_t wait_a, std::shared_ptr node_a, rai::system & system_a) : count (count_a), wait (wait_a), - client (client_a), + node (node_a), system (system_a) { } @@ -4349,23 +4349,23 @@ public: { auto count_l (count - 1); count = count_l - 1; - system.generate_activity (*client); + system.generate_activity (*node); if (count_l > 0) { auto this_l (shared_from_this ()); - client->service.add (std::chrono::system_clock::now () + std::chrono::milliseconds (wait), [this_l] () {this_l->run ();}); + node->service.add (std::chrono::system_clock::now () + std::chrono::milliseconds (wait), [this_l] () {this_l->run ();}); } } uint32_t count; uint32_t wait; - std::shared_ptr client; + std::shared_ptr node; rai::system & system; }; } void rai::system::generate_usage_traffic (uint32_t count_a, uint32_t wait_a) { - for (size_t i (0), n (clients.size ()); i != n; ++i) + for (size_t i (0), n (nodes.size ()); i != n; ++i) { generate_usage_traffic (count_a, wait_a, i); } @@ -4373,22 +4373,22 @@ void rai::system::generate_usage_traffic (uint32_t count_a, uint32_t wait_a) void rai::system::generate_usage_traffic (uint32_t count_a, uint32_t wait_a, size_t index_a) { - assert (clients.size () > index_a); + assert (nodes.size () > index_a); assert (count_a > 0); - auto generate (std::make_shared (count_a, wait_a, clients [index_a], *this)); + auto generate (std::make_shared (count_a, wait_a, nodes [index_a], *this)); generate->run (); } -void rai::system::generate_activity (rai::client & client_a) +void rai::system::generate_activity (rai::node & node_a) { auto what (random_pool.GenerateByte ()); - if (what < 0xc0 && client_a.store.latest_begin () != client_a.store.latest_end ()) + if (what < 0xc0 && node_a.store.latest_begin () != node_a.store.latest_end ()) { - generate_send_existing (client_a); + generate_send_existing (node_a); } else { - generate_send_new (client_a); + generate_send_new (node_a); } size_t polled; do @@ -4399,9 +4399,9 @@ void rai::system::generate_activity (rai::client & client_a) } while (polled != 0); } -rai::uint128_t rai::system::get_random_amount (rai::client & client_a) +rai::uint128_t rai::system::get_random_amount (rai::node & node_a) { - rai::uint128_t balance (wallet (0)->store.balance (client_a.ledger)); + rai::uint128_t balance (wallet (0)->store.balance (node_a.ledger)); std::string balance_text (balance.convert_to ()); rai::uint128_union random_amount; random_pool.GenerateBlock (random_amount.bytes.data (), sizeof (random_amount.bytes)); @@ -4410,28 +4410,28 @@ rai::uint128_t rai::system::get_random_amount (rai::client & client_a) return result; } -void rai::system::generate_send_existing (rai::client & client_a) +void rai::system::generate_send_existing (rai::node & node_a) { rai::account account; random_pool.GenerateBlock (account.bytes.data (), sizeof (account.bytes)); - rai::account_iterator entry (client_a.store.latest_begin (account)); - if (entry == client_a.store.latest_end ()) + rai::account_iterator entry (node_a.store.latest_begin (account)); + if (entry == node_a.store.latest_end ()) { - entry = client_a.store.latest_begin (); + entry = node_a.store.latest_begin (); } - assert (entry != client_a.store.latest_end ()); - wallet (0)->send (entry->first, get_random_amount (client_a)); + assert (entry != node_a.store.latest_end ()); + wallet (0)->send (entry->first, get_random_amount (node_a)); } -void rai::system::generate_send_new (rai::client & client_a) +void rai::system::generate_send_new (rai::node & node_a) { - assert (client_a.wallets.items.size () == 1); + assert (node_a.wallets.items.size () == 1); rai::keypair key; - client_a.wallets.items.begin ()->second->store.insert (key.prv); - client_a.wallets.items.begin ()->second->send (key.pub, get_random_amount (client_a)); + node_a.wallets.items.begin ()->second->store.insert (key.prv); + node_a.wallets.items.begin ()->second->send (key.pub, get_random_amount (node_a)); } -void rai::system::generate_mass_activity (uint32_t count_a, rai::client & client_a) +void rai::system::generate_mass_activity (uint32_t count_a, rai::node & node_a) { auto previous (std::chrono::system_clock::now ()); for (uint32_t i (0); i < count_a; ++i) @@ -4443,7 +4443,7 @@ void rai::system::generate_mass_activity (uint32_t count_a, rai::client & client std::cerr << boost::str (boost::format ("Mass activity iteration %1% ms %2% ms/t %3%\n") % i % ms % (ms / 256)); previous = now; } - generate_activity (client_a); + generate_activity (node_a); } } @@ -4459,14 +4459,14 @@ rai::uint128_t rai::wallet_store::balance (rai::ledger & ledger_a) return result; } -rai::election::election (std::shared_ptr client_a, rai::block const & block_a) : +rai::election::election (std::shared_ptr node_a, rai::block const & block_a) : votes (block_a.root ()), -client (client_a), +node (node_a), last_vote (std::chrono::system_clock::now ()), last_winner (block_a.clone ()), confirmed (false) { - assert (client_a->store.block_exists (block_a.hash ())); + assert (node_a->store.block_exists (block_a.hash ())); rai::keypair anonymous; rai::vote vote_l; vote_l.account = anonymous.pub; @@ -4478,10 +4478,10 @@ confirmed (false) void rai::election::start () { - auto client_l (client.lock ()); - if (client_l != nullptr) + auto node_l (node.lock ()); + if (node_l != nullptr) { - auto have_representative (client_l->representative_vote (*this, *last_winner)); + auto have_representative (node_l->representative_vote (*this, *last_winner)); if (have_representative) { announce_vote (); @@ -4492,19 +4492,19 @@ void rai::election::start () void rai::election::timeout_action () { - auto client_l (client.lock ()); - if (client_l != nullptr) + auto node_l (node.lock ()); + if (node_l != nullptr) { auto now (std::chrono::system_clock::now ()); if (now - last_vote < std::chrono::seconds (15)) { auto this_l (shared_from_this ()); - client_l->service.add (now + std::chrono::seconds (15), [this_l] () {this_l->timeout_action ();}); + node_l->service.add (now + std::chrono::seconds (15), [this_l] () {this_l->timeout_action ();}); } else { auto root_l (votes.id); - client_l->conflicts.stop (root_l); + node_l->conflicts.stop (root_l); } } } @@ -4521,35 +4521,35 @@ rai::uint128_t rai::election::contested_threshold (rai::ledger & ledger_a) void rai::election::vote (rai::vote const & vote_a) { - auto client_l (client.lock ()); - if (client_l != nullptr) + auto node_l (node.lock ()); + if (node_l != nullptr) { auto changed (votes.vote (vote_a)); if (!confirmed && changed) { - auto tally_l (client_l->ledger.tally (votes)); + auto tally_l (node_l->ledger.tally (votes)); assert (tally_l.size () > 0); auto winner (tally_l.begin ()->second->clone ()); if (!(*winner == *last_winner)) { - client_l->ledger.rollback (last_winner->hash ()); - client_l->ledger.process (*winner); + node_l->ledger.rollback (last_winner->hash ()); + node_l->ledger.process (*winner); last_winner = std::move (winner); } if (tally_l.size () == 1) { - if (tally_l.begin ()->first > uncontested_threshold (client_l->ledger)) + if (tally_l.begin ()->first > uncontested_threshold (node_l->ledger)) { confirmed = true; - client_l->processor.process_confirmed (*last_winner); + node_l->processor.process_confirmed (*last_winner); } } else { - if (tally_l.begin ()->first > contested_threshold (client_l->ledger)) + if (tally_l.begin ()->first > contested_threshold (node_l->ledger)) { confirmed = true; - client_l->processor.process_confirmed (*last_winner); + node_l->processor.process_confirmed (*last_winner); } } } @@ -4558,31 +4558,31 @@ void rai::election::vote (rai::vote const & vote_a) void rai::election::start_request (rai::block const & block_a) { - auto client_l (client.lock ()); - if (client_l != nullptr) + auto node_l (node.lock ()); + if (node_l != nullptr) { - auto list (client_l->peers.list ()); + auto list (node_l->peers.list ()); for (auto i (list.begin ()), j (list.end ()); i != j; ++i) { - client_l->network.send_confirm_req (i->endpoint, block_a); + node_l->network.send_confirm_req (i->endpoint, block_a); } } } void rai::election::announce_vote () { - auto client_l (client.lock ()); - if (client_l != nullptr) + auto node_l (node.lock ()); + if (node_l != nullptr) { - auto winner_l (client_l->ledger.winner (votes)); + auto winner_l (node_l->ledger.winner (votes)); assert (winner_l.second != nullptr); - auto list (client_l->peers.list ()); - client_l->network.confirm_broadcast (list, std::move (winner_l.second), votes.sequence); + auto list (node_l->peers.list ()); + node_l->network.confirm_broadcast (list, std::move (winner_l.second), votes.sequence); auto now (std::chrono::system_clock::now ()); if (now - last_vote < std::chrono::seconds (15)) { auto this_l (shared_from_this ()); - client_l->service.add (now + std::chrono::seconds (15), [this_l] () {this_l->announce_vote ();}); + node_l->service.add (now + std::chrono::seconds (15), [this_l] () {this_l->announce_vote ();}); } } } @@ -4594,8 +4594,8 @@ void rai::conflicts::start (rai::block const & block_a, bool request_a) auto existing (roots.find (root)); if (existing == roots.end ()) { - auto election (std::make_shared (client.shared (), block_a)); - client.service.add (std::chrono::system_clock::now (), [election] () {election->start ();}); + auto election (std::make_shared (node.shared (), block_a)); + node.service.add (std::chrono::system_clock::now (), [election] () {election->start ();}); roots.insert (std::make_pair (root, election)); if (request_a) { @@ -4642,14 +4642,14 @@ void rai::conflicts::stop (rai::block_hash const & root_a) roots.erase (root_a); } -rai::conflicts::conflicts (rai::client & client_a) : -client (client_a) +rai::conflicts::conflicts (rai::node & node_a) : +node (node_a) { } void rai::processor::process_message (rai::message & message_a, rai::endpoint const & sender_a) { - network_message_visitor visitor (client, sender_a); + network_message_visitor visitor (node, sender_a); message_a.visit (visitor); } @@ -4658,14 +4658,14 @@ namespace class confirmed_visitor : public rai::block_visitor { public: - confirmed_visitor (rai::client & client_a) : - client (client_a) + confirmed_visitor (rai::node & node_a) : + node (node_a) { } void send_block (rai::send_block const & block_a) override { rai::private_key prv; - for (auto i (client.wallets.items.begin ()), n (client.wallets.items.end ()); i != n; ++i) + for (auto i (node.wallets.items.begin ()), n (node.wallets.items.end ()); i != n; ++i) { if (!i->second->store.fetch (block_a.hashables.destination, prv)) { @@ -4674,7 +4674,7 @@ public: } else { - BOOST_LOG (client.log) << "While confirming, unable to fetch wallet key"; + BOOST_LOG (node.log) << "While confirming, unable to fetch wallet key"; } } } @@ -4687,17 +4687,17 @@ public: void change_block (rai::change_block const &) override { } - rai::client & client; + rai::node & node; }; } void rai::processor::process_confirmed (rai::block const & confirmed_a) { - confirmed_visitor visitor (client); + confirmed_visitor visitor (node); confirmed_a.visit (visitor); } -bool rai::client::representative_vote (rai::election & election_a, rai::block const & block_a) +bool rai::node::representative_vote (rai::election & election_a, rai::block const & block_a) { bool result (false); for (auto i (wallets.items.begin ()), n (wallets.items.end ()); i != n; ++i) diff --git a/rai/core/core.hpp b/rai/node.hpp similarity index 93% rename from rai/core/core.hpp rename to rai/node.hpp index 5ea2fa3b..e6bd2e36 100644 --- a/rai/core/core.hpp +++ b/rai/node.hpp @@ -86,11 +86,11 @@ struct hash namespace rai { -class client; +class node; class election : public std::enable_shared_from_this { public: - election (std::shared_ptr , rai::block const &); + election (std::shared_ptr , rai::block const &); void start (); void vote (rai::vote const &); void announce_vote (); @@ -99,7 +99,7 @@ public: rai::uint128_t uncontested_threshold (rai::ledger &); rai::uint128_t contested_threshold (rai::ledger &); rai::votes votes; - std::weak_ptr client; + std::weak_ptr node; std::chrono::system_clock::time_point last_vote; std::unique_ptr last_winner; bool confirmed; @@ -107,13 +107,13 @@ public: class conflicts { public: - conflicts (rai::client &); + conflicts (rai::node &); void start (rai::block const &, bool); bool no_conflict (rai::block_hash const &); void update (rai::vote const &); void stop (rai::block_hash const &); std::unordered_map > roots; - rai::client & client; + rai::node & node; std::mutex mutex; }; enum class message_type : uint8_t @@ -313,25 +313,25 @@ public: class wallet { public: - wallet (bool &, rai::client &, boost::filesystem::path const &); - wallet (bool &, rai::client &, boost::filesystem::path const &, std::string const &); + wallet (bool &, rai::node &, boost::filesystem::path const &); + wallet (bool &, rai::node &, boost::filesystem::path const &, std::string const &); bool receive (rai::send_block const &, rai::private_key const &, rai::account const &); bool send (rai::account const &, rai::uint128_t const &); bool import (std::string const &, std::string const &); std::mutex mutex; rai::wallet_store store; - rai::client & client; + rai::node & node; }; class wallets { public: - wallets (rai::client &, boost::filesystem::path const &); + wallets (rai::node &, boost::filesystem::path const &); std::shared_ptr open (rai::uint256_union const &); std::shared_ptr create (rai::uint256_union const &); void destroy (rai::uint256_union const &); std::unordered_map > items; boost::filesystem::path const path; - rai::client & client; + rai::node & node; }; class operation { @@ -368,7 +368,7 @@ public: class gap_cache { public: - gap_cache (rai::client &); + gap_cache (rai::node &); void add (rai::block const &, rai::block_hash); std::unique_ptr get (rai::block_hash const &); void vote (rai::vote const &); @@ -385,12 +385,12 @@ public: > blocks; size_t const max = 128; std::mutex mutex; - rai::client & client; + rai::node & node; }; class processor { public: - processor (rai::client &); + processor (rai::node &); void stop (); void contacted (rai::endpoint const &); void find_network (std::vector > const &); @@ -403,7 +403,7 @@ public: void process_confirmed (rai::block const &); void search_pending (); void ongoing_keepalive (); - rai::client & client; + rai::node & node; static std::chrono::seconds constexpr period = std::chrono::seconds (60); static std::chrono::seconds constexpr cutoff = period * 5; std::mutex mutex; @@ -443,12 +443,12 @@ public: class bootstrap_client : public std::enable_shared_from_this { public: - bootstrap_client (std::shared_ptr , std::function const & = [] () {}); + bootstrap_client (std::shared_ptr , std::function const & = [] () {}); ~bootstrap_client (); void run (rai::tcp_endpoint const &); void connect_action (boost::system::error_code const &); void sent_request (boost::system::error_code const &, size_t); - std::shared_ptr client; + std::shared_ptr node; boost::asio::ip::tcp::socket socket; std::function completion_action; }; @@ -557,7 +557,7 @@ public: class network { public: - network (boost::asio::io_service &, uint16_t, rai::client &); + network (boost::asio::io_service &, uint16_t, rai::node &); void receive (); void stop (); void receive_action (boost::system::error_code const &, size_t); @@ -578,7 +578,7 @@ public: std::mutex socket_mutex; boost::asio::io_service & service; boost::asio::ip::udp::resolver resolver; - rai::client & client; + rai::node & node; uint64_t bad_sender_count; std::queue >> sends; bool on; @@ -594,20 +594,20 @@ public: class bootstrap_initiator { public: - bootstrap_initiator (rai::client &); + bootstrap_initiator (rai::node &); void warmup (rai::endpoint const &); void bootstrap (rai::endpoint const &); void bootstrap_any (); void initiate (rai::endpoint const &); std::mutex mutex; - rai::client & client; + rai::node & node; bool in_progress; bool warmed_up; }; class bootstrap_listener { public: - bootstrap_listener (boost::asio::io_service &, uint16_t, rai::client &); + bootstrap_listener (boost::asio::io_service &, uint16_t, rai::node &); void start (); void stop (); void accept_connection (); @@ -616,13 +616,13 @@ public: boost::asio::ip::tcp::acceptor acceptor; rai::tcp_endpoint local; boost::asio::io_service & service; - rai::client & client; + rai::node & node; bool on; }; class bootstrap_server : public std::enable_shared_from_this { public: - bootstrap_server (std::shared_ptr , std::shared_ptr ); + bootstrap_server (std::shared_ptr , std::shared_ptr ); ~bootstrap_server (); void receive (); void receive_header_action (boost::system::error_code const &, size_t); @@ -634,7 +634,7 @@ public: void run_next (); std::array receive_buffer; std::shared_ptr socket; - std::shared_ptr client; + std::shared_ptr node; std::mutex mutex; std::queue > requests; }; @@ -684,35 +684,35 @@ public: class rpc { public: - rpc (boost::shared_ptr , boost::shared_ptr , boost::asio::ip::address_v6 const &, uint16_t, rai::client &, bool); + rpc (boost::shared_ptr , boost::shared_ptr , boost::asio::ip::address_v6 const &, uint16_t, rai::node &, bool); void start (); void stop (); boost::network::http::server server; void operator () (boost::network::http::server ::request const &, boost::network::http::server ::response &); void log (const char *) {} - rai::client & client; + rai::node & node; bool on; bool enable_control; }; -class client_init +class node_init { public: - client_init (); + node_init (); bool error (); leveldb::Status block_store_init; bool wallet_init; bool ledger_init; }; -class client : public std::enable_shared_from_this +class node : public std::enable_shared_from_this { public: - client (rai::client_init &, boost::shared_ptr , uint16_t, boost::filesystem::path const &, rai::processor_service &); - client (rai::client_init &, boost::shared_ptr , uint16_t, rai::processor_service &); - ~client (); + node (rai::node_init &, boost::shared_ptr , uint16_t, boost::filesystem::path const &, rai::processor_service &); + node (rai::node_init &, boost::shared_ptr , uint16_t, rai::processor_service &); + ~node (); void send_keepalive (rai::endpoint const &); void start (); void stop (); - std::shared_ptr shared (); + std::shared_ptr shared (); bool representative_vote (rai::election &, rai::block const &); void work_create (rai::block &); void vote (rai::vote const &); @@ -740,17 +740,17 @@ class system public: system (uint16_t, size_t); ~system (); - void generate_activity (rai::client &); - void generate_mass_activity (uint32_t, rai::client &); + void generate_activity (rai::node &); + void generate_mass_activity (uint32_t, rai::node &); void generate_usage_traffic (uint32_t, uint32_t, size_t); void generate_usage_traffic (uint32_t, uint32_t); - rai::uint128_t get_random_amount (rai::client &); - void generate_send_new (rai::client &); - void generate_send_existing (rai::client &); + rai::uint128_t get_random_amount (rai::node &); + void generate_send_new (rai::node &); + void generate_send_existing (rai::node &); std::shared_ptr wallet (size_t); boost::shared_ptr service; rai::processor_service processor; - std::vector > clients; + std::vector > nodes; }; extern std::chrono::milliseconds const confirm_wait; } \ No newline at end of file diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index ff085c25..67870b90 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -6,8 +6,8 @@ #include -rai_qt::client::client (QApplication & application_a, rai::client & client_a, rai::uint256_union const & wallet_a) : -client_m (client_a), +rai_qt::client::client (QApplication & application_a, rai::node & node_a, rai::uint256_union const & wallet_a) : +node (node_a), password_change (*this), enter_password (*this), advanced (*this), @@ -34,10 +34,10 @@ send_count (new QLineEdit), send_blocks_send (new QPushButton ("Send")), send_blocks_back (new QPushButton ("Back")) { - wallet = client_m.wallets.open (wallet_a); + wallet = node.wallets.open (wallet_a); if (wallet == nullptr) { - wallet = client_m.wallets.create (wallet_a); + wallet = node.wallets.create (wallet_a); } send_blocks_layout->addWidget (send_account_label); send_blocks_layout->addWidget (send_account); @@ -157,21 +157,21 @@ send_blocks_back (new QPushButton ("Back")) wallet->store.insert (key.prv); refresh_wallet (); }); - client_m.send_observers.push_back ([this] (rai::send_block const &, rai::account const & account_a, rai::amount const &) + node.send_observers.push_back ([this] (rai::send_block const &, rai::account const & account_a, rai::amount const &) { if (wallet->store.exists (account_a)) { refresh_wallet (); } }); - client_m.receive_observers.push_back ([this] (rai::receive_block const &, rai::account const & account_a, rai::amount const &) + node.receive_observers.push_back ([this] (rai::receive_block const &, rai::account const & account_a, rai::amount const &) { if (wallet->store.exists (account_a)) { refresh_wallet (); } }); - client_m.open_observers.push_back ([this] (rai::open_block const &, rai::account const & account_a, rai::amount const &, rai::account const &) + node.open_observers.push_back ([this] (rai::open_block const &, rai::account const & account_a, rai::amount const &, rai::account const &) { if (wallet->store.exists (account_a)) { @@ -190,7 +190,7 @@ void rai_qt::client::refresh_wallet () QList items; std::string account; rai::public_key key (i->first); - auto account_balance (client_m.ledger.account_balance (key)); + auto account_balance (node.ledger.account_balance (key)); balance += account_balance; auto balance (std::to_string (rai::scale_down (account_balance))); items.push_back (new QStandardItem (balance.c_str ())); @@ -457,7 +457,7 @@ client (client_a) }); QObject::connect (search_for_receivables, &QPushButton::released, [this] () { - client.client_m.processor.search_pending (); + client.node.processor.search_pending (); }); QObject::connect (create_block, &QPushButton::released, [this] () { @@ -473,7 +473,7 @@ client (client_a) void rai_qt::advanced_actions::refresh_peers () { QStringList peers; - for (auto i: client.client_m.peers.list ()) + for (auto i: client.node.peers.list ()) { std::stringstream endpoint; endpoint << i.endpoint.address ().to_string (); @@ -492,13 +492,13 @@ void rai_qt::advanced_actions::refresh_peers () void rai_qt::advanced_actions::refresh_ledger () { ledger_model->removeRows (0, ledger_model->rowCount ()); - for (auto i (client.client_m.ledger.store.latest_begin()), j (client.client_m.ledger.store.latest_end ()); i != j; ++i) + for (auto i (client.node.ledger.store.latest_begin()), j (client.node.ledger.store.latest_end ()); i != j; ++i) { QList items; std::string account; i->first.encode_base58check (account); items.push_back (new QStandardItem (QString (account.c_str ()))); - items.push_back (new QStandardItem (QString (std::to_string (rai::scale_down (client.client_m.ledger.balance (i->second.hash))).c_str ()))); + items.push_back (new QStandardItem (QString (std::to_string (rai::scale_down (client.node.ledger.balance (i->second.hash))).c_str ()))); std::string block_hash; i->second.hash.encode_hex (block_hash); items.push_back (new QStandardItem (QString (block_hash.c_str ()))); @@ -531,7 +531,7 @@ client (client_a) auto block_l (rai::deserialize_block_json (tree)); if (block_l != nullptr) { - client.client_m.processor.process_receive_republish (std::move (block_l)); + client.node.processor.process_receive_republish (std::move (block_l)); } else { @@ -729,11 +729,11 @@ void rai_qt::block_creation::create_send () rai::private_key key; if (!client.wallet->store.fetch (account_l, key)) { - auto balance (client.client_m.ledger.account_balance (account_l)); + auto balance (client.node.ledger.account_balance (account_l)); if (amount_l.number () <= balance) { rai::frontier frontier; - auto error (client.client_m.store.latest_get (account_l, frontier)); + auto error (client.node.store.latest_get (account_l, frontier)); assert (!error); rai::send_block send; send.hashables.destination = destination_l; @@ -741,7 +741,7 @@ void rai_qt::block_creation::create_send () send.hashables.balance = rai::amount (balance - amount_l.number ()); rai::sign_message (key, account_l, send.hash (), send.signature); key.clear (); - client.client_m.work_create (send); + client.node.work_create (send); std::string block_l; send.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); @@ -786,10 +786,10 @@ void rai_qt::block_creation::create_receive () if (!error) { rai::receivable receivable; - if (!client.client_m.store.pending_get (source_l, receivable)) + if (!client.node.store.pending_get (source_l, receivable)) { rai::frontier frontier; - auto error (client.client_m.store.latest_get (receivable.destination, frontier)); + auto error (client.node.store.latest_get (receivable.destination, frontier)); if (!error) { rai::private_key key; @@ -801,7 +801,7 @@ void rai_qt::block_creation::create_receive () receive.hashables.source = source_l; rai::sign_message (key, receivable.destination, receive.hash (), receive.signature); key.clear (); - client.client_m.work_create (receive); + client.node.work_create (receive); std::string block_l; receive.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); @@ -844,7 +844,7 @@ void rai_qt::block_creation::create_change () if (!error) { rai::frontier frontier; - auto error (client.client_m.store.latest_get (account_l, frontier)); + auto error (client.node.store.latest_get (account_l, frontier)); if (!error) { rai::private_key key; @@ -853,7 +853,7 @@ void rai_qt::block_creation::create_change () { rai::change_block change (representative_l, frontier.hash, key, account_l); key.clear (); - client.client_m.work_create (change); + client.node.work_create (change); std::string block_l; change.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); @@ -896,10 +896,10 @@ void rai_qt::block_creation::create_open () if (!error) { rai::receivable receivable; - if (!client.client_m.store.pending_get (source_l, receivable)) + if (!client.node.store.pending_get (source_l, receivable)) { rai::frontier frontier; - auto error (client.client_m.store.latest_get (receivable.destination, frontier)); + auto error (client.node.store.latest_get (receivable.destination, frontier)); if (error) { rai::private_key key; @@ -911,7 +911,7 @@ void rai_qt::block_creation::create_open () open.hashables.representative = representative_l; rai::sign_message (key, receivable.destination, open.hash (), open.signature); key.clear (); - client.client_m.work_create (open); + client.node.work_create (open); std::string block_l; open.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); diff --git a/rai/qt/qt.hpp b/rai/qt/qt.hpp index f1ed71e1..7c52249d 100644 --- a/rai/qt/qt.hpp +++ b/rai/qt/qt.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -129,9 +129,9 @@ namespace rai_qt { class client { public: - client (QApplication &, rai::client &, rai::uint256_union const &); + client (QApplication &, rai::node &, rai::uint256_union const &); ~client (); - rai::client & client_m; + rai::node & node; rai_qt::password_change password_change; rai_qt::enter_password enter_password; rai_qt::advanced_actions advanced; diff --git a/rai/qt_client/entry.cpp b/rai/qt_client/entry.cpp index d63739f1..22690adf 100644 --- a/rai/qt_client/entry.cpp +++ b/rai/qt_client/entry.cpp @@ -95,8 +95,8 @@ int main (int argc, char * const * argv) QApplication application (argc, const_cast (argv)); auto service (boost::make_shared ()); rai::processor_service processor; - rai::client_init init; - auto client (std::make_shared (init, service, config.peering_port, working, processor)); + rai::node_init init; + auto client (std::make_shared (init, service, config.peering_port, working, processor)); QObject::connect (&application, &QApplication::aboutToQuit, [&] () { client->stop (); diff --git a/rai/qt_system/entry.cpp b/rai/qt_system/entry.cpp index 0cd37b01..03b12358 100644 --- a/rai/qt_system/entry.cpp +++ b/rai/qt_system/entry.cpp @@ -13,7 +13,7 @@ int main (int argc, char ** argv) { rai::uint256_union wallet; rai::random_pool.GenerateBlock (wallet.bytes.data (), wallet.bytes.size ()); - guis.push_back (std::unique_ptr (new rai_qt::client (application, *system.clients [i], wallet))); + guis.push_back (std::unique_ptr (new rai_qt::client (application, *system.nodes [i], wallet))); client_tabs->addTab (guis.back ()->client_window, boost::str (boost::format ("Client %1%") % i).c_str ()); } client_tabs->show (); @@ -41,7 +41,7 @@ int main (int argc, char ** argv) }); QObject::connect (&application, &QApplication::aboutToQuit, [&] () { - for (auto & i: system.clients) + for (auto & i: system.nodes) { i->stop (); } diff --git a/rai/qt_test/qt.cpp b/rai/qt_test/qt.cpp index 918b8f00..5313fe21 100644 --- a/rai/qt_test/qt.cpp +++ b/rai/qt_test/qt.cpp @@ -12,7 +12,7 @@ TEST (client, construction) rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], rai::uint256_union ()); + rai_qt::client client (application, *system.nodes [0], rai::uint256_union ()); } TEST (client, main) @@ -20,7 +20,7 @@ TEST (client, main) rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], rai::uint256_union ()); + rai_qt::client client (application, *system.nodes [0], rai::uint256_union ()); ASSERT_EQ (client.entry_window, client.main_stack->currentWidget ()); QTest::mouseClick (client.send_blocks, Qt::LeftButton); ASSERT_EQ (client.send_blocks_window, client.main_stack->currentWidget ()); @@ -48,7 +48,7 @@ TEST (client, password_change) rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first); + rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); QTest::mouseClick (client.show_advanced, Qt::LeftButton); QTest::mouseClick (client.advanced.change_password, Qt::LeftButton); ASSERT_NE (system.wallet (0)->store.derive_key ("1"), system.wallet (0)->store.password.value ()); @@ -65,7 +65,7 @@ TEST (client, password_nochange) rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first); + rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); QTest::mouseClick (client.show_advanced, Qt::LeftButton); QTest::mouseClick (client.advanced.change_password, Qt::LeftButton); ASSERT_EQ (system.wallet (0)->store.derive_key (""), system.wallet (0)->store.password.value ()); @@ -82,7 +82,7 @@ TEST (client, enter_password) rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first); + rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.valid)); ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.password)); ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.unlock)); @@ -111,17 +111,17 @@ TEST (client, send) system.wallet (1)->store.insert (key1.prv); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first); + rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); QTest::mouseClick (client.send_blocks, Qt::LeftButton); QTest::keyClicks (client.send_account, account.c_str ()); QTest::keyClicks (client.send_count, "2"); QTest::mouseClick (client.send_blocks_send, Qt::LeftButton); - while (client.client_m.ledger.account_balance (key1.pub).is_zero ()) + while (client.node.ledger.account_balance (key1.pub).is_zero ()) { system.service->poll_one (); system.processor.poll_one (); } - ASSERT_EQ (rai::scale_up (2), client.client_m.ledger.account_balance (key1.pub)); + ASSERT_EQ (rai::scale_up (2), client.node.ledger.account_balance (key1.pub)); QTest::mouseClick (client.send_blocks_back, Qt::LeftButton); QTest::mouseClick (client.show_advanced, Qt::LeftButton); QTest::mouseClick (client.advanced.show_ledger, Qt::LeftButton); @@ -138,7 +138,7 @@ TEST (client, process_block) rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first); + rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); ASSERT_EQ ("Process", client.block_entry.process->text ()); ASSERT_EQ ("Back", client.block_entry.back->text ()); rai::keypair key1; @@ -148,9 +148,9 @@ TEST (client, process_block) ASSERT_EQ (client.block_entry.window, client.main_stack->currentWidget ()); rai::send_block send; send.hashables.destination = key1.pub; - send.hashables.previous = system.clients [0]->ledger.latest (rai::genesis_account); + send.hashables.previous = system.nodes [0]->ledger.latest (rai::genesis_account); send.hashables.balance = 0; - system.clients [0]->work_create (send); + system.nodes [0]->work_create (send); rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send.hash (), send.signature); std::string destination; send.hashables.destination.encode_base58check (destination); @@ -163,7 +163,7 @@ TEST (client, process_block) auto block_json (boost::str (boost::format ("{\"type\": \"send\", \"previous\": \"%1%\", \"balance\": \"%2%\", \"destination\": \"%3%\", \"work\": \"%4%\", \"signature\": \"%5%\"}") % previous % balance % destination % rai::to_string_hex (send.work) % signature)); QTest::keyClicks (client.block_entry.block, block_json.c_str ()); QTest::mouseClick (client.block_entry.process, Qt::LeftButton); - ASSERT_EQ (send.hash (), system.clients [0]->ledger.latest (rai::genesis_account)); + ASSERT_EQ (send.hash (), system.nodes [0]->ledger.latest (rai::genesis_account)); QTest::mouseClick(client.block_entry.back, Qt::LeftButton); ASSERT_EQ (client.advanced.window, client.main_stack->currentWidget ()); } @@ -176,7 +176,7 @@ TEST (client, create_send) system.wallet (0)->store.insert (key.prv); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first); + rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); QTest::mouseClick (client.show_advanced, Qt::LeftButton); QTest::mouseClick (client.advanced.create_block, Qt::LeftButton); QTest::mouseClick (client.block_creation.send, Qt::LeftButton); @@ -195,6 +195,6 @@ TEST (client, create_send) std::stringstream istream (json); boost::property_tree::read_json (istream, tree1); ASSERT_FALSE (send.deserialize_json (tree1)); - ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (send)); - ASSERT_EQ (rai::process_result::old, system.clients [0]->ledger.process (send)); + ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (send)); + ASSERT_EQ (rai::process_result::old, system.nodes [0]->ledger.process (send)); } \ No newline at end of file diff --git a/rai/slow_test/client.cpp b/rai/slow_test/node.cpp similarity index 59% rename from rai/slow_test/client.cpp rename to rai/slow_test/node.cpp index a5e2ee61..19dd7536 100644 --- a/rai/slow_test/client.cpp +++ b/rai/slow_test/node.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include @@ -8,9 +8,9 @@ TEST (system, generate_mass_activity) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); size_t count (20); - system.generate_mass_activity (count, *system.clients [0]); + system.generate_mass_activity (count, *system.nodes [0]); size_t accounts (0); - for (auto i (system.clients [0]->store.latest_begin ()), n (system.clients [0]->store.latest_end ()); i != n; ++i) + for (auto i (system.nodes [0]->store.latest_begin ()), n (system.nodes [0]->store.latest_end ()); i != n; ++i) { ++accounts; } @@ -22,9 +22,9 @@ TEST (system, generate_mass_activity_long) rai::system system (24000, 1); system.wallet (0)->store.insert (rai::test_genesis_key.prv); size_t count (10000); - system.generate_mass_activity (count, *system.clients [0]); + system.generate_mass_activity (count, *system.nodes [0]); size_t accounts (0); - for (auto i (system.clients [0]->store.latest_begin ()), n (system.clients [0]->store.latest_end ()); i != n; ++i) + for (auto i (system.nodes [0]->store.latest_begin ()), n (system.nodes [0]->store.latest_end ()); i != n; ++i) { ++accounts; }