From a22e8502da0874feedf9e5d6e136ff43b79316ab Mon Sep 17 00:00:00 2001 From: manikey123 Date: Thu, 3 Jan 2019 18:16:36 -0800 Subject: [PATCH 01/20] added test case for 782 part1 --- libraries/app/api.cpp | 3 +- libraries/app/application.cpp | 11 +++ .../app/include/graphene/app/application.hpp | 3 +- tests/common/database_fixture.cpp | 5 ++ tests/tests/history_api_tests.cpp | 70 +++++++++++++++++++ 5 files changed, 90 insertions(+), 2 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 61e9637a9f..38bffb56af 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -352,7 +352,8 @@ namespace graphene { namespace app { { FC_ASSERT( _app.chain_database() ); const auto& db = *_app.chain_database(); - FC_ASSERT( limit <= 100 ); + uint32_t max_account_history_operations_limit=_app.get_options().max_account_history_operations_limit; + FC_ASSERT(limit <= max_account_history_operations_limit); vector result; account_id_type account; try { diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index f2cf80285d..c3144daef5 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -439,6 +439,11 @@ void application_impl::startup() if ( _options->count("enable-subscribe-to-all") ) _app_options.enable_subscribe_to_all = _options->at( "enable-subscribe-to-all" ).as(); + if ( _options->count("max-account-history-operations-limit") ) + { + _app_options.max_account_history_operations_limit = _options->at("max-account-history-operations-limit").as(); + } + if( _active_plugins.find( "market_history" ) != _active_plugins.end() ) _app_options.has_market_history_plugin = true; @@ -982,6 +987,8 @@ void application::set_program_options(boost::program_options::options_descriptio ("enable-standby-votes-tracking", bpo::value()->implicit_value(true), "Whether to enable tracking of votes of standby witnesses and committee members. " "Set it to true to provide accurate data to API clients, set to false for slightly better performance.") + ("max-account-history-operations-limit",boost::program_options::value()->default_value(100), + "for history_api::get_account_history_operations to set its limit value default ass 100") ; command_line_options.add(configuration_file_options); command_line_options.add_options() @@ -1096,6 +1103,10 @@ void application::set_block_production(bool producing_blocks) { my->_is_block_producer = producing_blocks; } +void application::set_options_max_account_history_operations_limit(const uint64_t& max_limit) +{ + my->_app_options.max_account_history_operations_limit=max_limit; +} optional< api_access_info > application::get_api_access_info( const string& username )const { diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 4892bb9a27..64f2c622a9 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -40,6 +40,7 @@ namespace graphene { namespace app { public: bool enable_subscribe_to_all = false; bool has_market_history_plugin = false; + uint64_t max_account_history_operations_limit=100; }; class application @@ -87,7 +88,7 @@ namespace graphene { namespace app { net::node_ptr p2p_node(); std::shared_ptr chain_database()const; - + void set_options_max_account_history_operations_limit(const uint64_t& max_limit); void set_block_production(bool producing_blocks); fc::optional< api_access_info > get_api_access_info( const string& username )const; void set_api_access_info(const string& username, api_access_info&& permissions); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index a77854cd22..4133a22d72 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -120,6 +120,11 @@ database_fixture::database_fixture() { options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)75, false))); } + if (current_test_name == "setting_max_operation_limit_get_account_history_operations") + { + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); + app.set_options_max_account_history_operations_limit(300); + } // add account tracking for ahplugin for special test case with track-account enabled if( !options.count("track-account") && current_test_name == "track_account") { std::vector track_account; diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index b8f8856384..997af6ece4 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -604,5 +604,75 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { throw; } } +//new test case for increasing the limit based on the config file +BOOST_AUTO_TEST_CASE(setting_max_operation_limit_get_account_history_operations) { + try { + graphene::app::history_api hist_api(app); + + //account_id_type() do 3 ops + create_bitasset("CNY", account_id_type()); + create_account("sam"); + create_account("alice"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + int asset_create_op_id = operation::tag::value; + int account_create_op_id = operation::tag::value; + int transfer_op_id = operation::tag::value; + + //account_id_type() did 1 asset_create op + vector histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); + + //account_id_type() did 2 account_create ops + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // No asset_create op larger than id1 + histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 200); + BOOST_CHECK_EQUAL(histories.size(), 0); + + // Limit 1 returns 1 result + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // alice has 1 op + histories = hist_api.get_account_history_operations( + "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // create a bunch of accounts + for(int i = 0; i < 126; ++i) + { + std::string acct_name = "mytempacct" + std::to_string(i); + create_account(acct_name); + } + generate_block(); + + // history is set to limit transactions to 125 (see database_fixture.hpp) + // so asking for more should only return 125 (and not throw exception, + // see https://github.com/bitshares/bitshares-core/issues/1490 + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 125); + BOOST_CHECK_EQUAL(histories.size(), 125); + if (histories.size() > 0) + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + + } catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } +} BOOST_AUTO_TEST_SUITE_END() From b4195aa58d08b1c3e13751f0badfc8c63fb02943 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Tue, 8 Jan 2019 01:18:59 -0800 Subject: [PATCH 02/20] Update history_api_tests.cpp updated based on comments --- tests/tests/history_api_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 997af6ece4..09a87c77df 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -664,7 +664,7 @@ BOOST_AUTO_TEST_CASE(setting_max_operation_limit_get_account_history_operations) // see https://github.com/bitshares/bitshares-core/issues/1490 histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 125); - BOOST_CHECK_EQUAL(histories.size(), 125); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); if (histories.size() > 0) BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); From 1829a9aaa0b428a2a890234e692a6eaf2246cf18 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Wed, 9 Jan 2019 03:20:55 -0800 Subject: [PATCH 03/20] updated based on review comment received --- libraries/app/application.cpp | 28 +++++++++++++------ libraries/app/application_impl.hxx | 1 + .../app/include/graphene/app/application.hpp | 2 +- tests/common/database_fixture.cpp | 10 +++++-- tests/tests/history_api_tests.cpp | 9 ++---- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index c3144daef5..326ed8468a 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -318,6 +318,13 @@ void application_impl::set_dbg_init_key( graphene::chain::genesis_state_type& ge genesis.initial_witness_candidates[i].block_signing_key = init_pubkey; } + +void application_impl::set_dgb_max_acct_history_opt_limit() { + if (_options->count("max-account-history-operations-limit")) { + _app_options.max_account_history_operations_limit = _options->at("max-account-history-operations-limit").as(); + } +} + void application_impl::startup() { try { fc::create_directories(_data_dir / "blockchain"); @@ -439,10 +446,7 @@ void application_impl::startup() if ( _options->count("enable-subscribe-to-all") ) _app_options.enable_subscribe_to_all = _options->at( "enable-subscribe-to-all" ).as(); - if ( _options->count("max-account-history-operations-limit") ) - { - _app_options.max_account_history_operations_limit = _options->at("max-account-history-operations-limit").as(); - } + set_dgb_max_acct_history_opt_limit(); if( _active_plugins.find( "market_history" ) != _active_plugins.end() ) _app_options.has_market_history_plugin = true; @@ -1083,6 +1087,18 @@ void application::startup() throw; } } +void application::set_dgb_max_acct_history_opt_limit() +{ + try { + my->set_dgb_max_acct_history_opt_limit(); + } catch ( const fc::exception& e ) { + elog( "${e}", ("e",e.to_detail_string()) ); + throw; + } catch ( ... ) { + elog( "unexpected exception" ); + throw; + } +} std::shared_ptr application::get_plugin(const string& name) const { @@ -1103,10 +1119,6 @@ void application::set_block_production(bool producing_blocks) { my->_is_block_producer = producing_blocks; } -void application::set_options_max_account_history_operations_limit(const uint64_t& max_limit) -{ - my->_app_options.max_account_history_operations_limit=max_limit; -} optional< api_access_info > application::get_api_access_info( const string& username )const { diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 9f601bce79..bda0377637 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -41,6 +41,7 @@ class application_impl : public net::node_delegate } void set_dbg_init_key( graphene::chain::genesis_state_type& genesis, const std::string& init_key ); + void set_dgb_max_acct_history_opt_limit(); void startup(); diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 64f2c622a9..4cb26d9186 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -88,7 +88,7 @@ namespace graphene { namespace app { net::node_ptr p2p_node(); std::shared_ptr chain_database()const; - void set_options_max_account_history_operations_limit(const uint64_t& max_limit); + void set_dgb_max_acct_history_opt_limit(); void set_block_production(bool producing_blocks); fc::optional< api_access_info > get_api_access_info( const string& username )const; void set_api_access_info(const string& username, api_access_info&& permissions); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 4133a22d72..fe21366958 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -122,8 +122,9 @@ database_fixture::database_fixture() } if (current_test_name == "setting_max_operation_limit_get_account_history_operations") { - options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); - app.set_options_max_account_history_operations_limit(300); + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); + options.insert(std::make_pair("max-account-history-operations-limit", boost::program_options::variable_value((uint64_t)300, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } // add account tracking for ahplugin for special test case with track-account enabled if( !options.count("track-account") && current_test_name == "track_account") { @@ -166,6 +167,11 @@ database_fixture::database_fixture() ahplugin->plugin_set_app(&app); ahplugin->plugin_initialize(options); ahplugin->plugin_startup(); + if (current_test_name == "setting_max_operation_limit_get_account_history_operations") + { + app.initialize(graphene::utilities::temp_directory_path(), options); + app.set_dgb_max_acct_history_opt_limit(); + } } if(current_test_name == "elasticsearch_objects" || current_test_name == "elasticsearch_suite") { diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 997af6ece4..4dcb44433d 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -662,12 +662,9 @@ BOOST_AUTO_TEST_CASE(setting_max_operation_limit_get_account_history_operations) // history is set to limit transactions to 125 (see database_fixture.hpp) // so asking for more should only return 125 (and not throw exception, // see https://github.com/bitshares/bitshares-core/issues/1490 - histories = hist_api.get_account_history_operations( - "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 125); - BOOST_CHECK_EQUAL(histories.size(), 125); - if (histories.size() > 0) - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - + GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type() ,operation_history_id_type(), 301), fc::exception) + histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); } catch (fc::exception &e) { edump((e.to_detail_string())); From ab7b44a41b6c663a77c99a5782badebd14b7cf47 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Wed, 9 Jan 2019 03:25:44 -0800 Subject: [PATCH 04/20] Update history_api_tests.cpp update the file for merge issue --- tests/tests/history_api_tests.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 62b346c3a0..056023b4f2 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -662,19 +662,9 @@ BOOST_AUTO_TEST_CASE(setting_max_operation_limit_get_account_history_operations) // history is set to limit transactions to 125 (see database_fixture.hpp) // so asking for more should only return 125 (and not throw exception, // see https://github.com/bitshares/bitshares-core/issues/1490 -<<<<<<< HEAD GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type() ,operation_history_id_type(), 301), fc::exception) histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); -======= - histories = hist_api.get_account_history_operations( - "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 125); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); - if (histories.size() > 0) - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - ->>>>>>> b4195aa58d08b1c3e13751f0badfc8c63fb02943 - + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); } catch (fc::exception &e) { edump((e.to_detail_string())); throw; From c3db2dbdd76a524f73de6d9ac63322db89c4e0ae Mon Sep 17 00:00:00 2001 From: manikey123 Date: Wed, 9 Jan 2019 03:31:49 -0800 Subject: [PATCH 05/20] Update application.cpp updated int value --- libraries/app/application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 326ed8468a..18826a1dd3 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -991,7 +991,7 @@ void application::set_program_options(boost::program_options::options_descriptio ("enable-standby-votes-tracking", bpo::value()->implicit_value(true), "Whether to enable tracking of votes of standby witnesses and committee members. " "Set it to true to provide accurate data to API clients, set to false for slightly better performance.") - ("max-account-history-operations-limit",boost::program_options::value()->default_value(100), + ("max-account-history-operations-limit",boost::program_options::value()->default_value(100), "for history_api::get_account_history_operations to set its limit value default ass 100") ; command_line_options.add(configuration_file_options); From 43a743be0c6771613a0804e64a960c16287cfbda Mon Sep 17 00:00:00 2001 From: manikey123 Date: Wed, 9 Jan 2019 03:33:50 -0800 Subject: [PATCH 06/20] updating uint64_t --- libraries/app/api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 38bffb56af..5a35bc8019 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -352,7 +352,7 @@ namespace graphene { namespace app { { FC_ASSERT( _app.chain_database() ); const auto& db = *_app.chain_database(); - uint32_t max_account_history_operations_limit=_app.get_options().max_account_history_operations_limit; + uint64_t max_account_history_operations_limit=_app.get_options().max_account_history_operations_limit; FC_ASSERT(limit <= max_account_history_operations_limit); vector result; account_id_type account; From 9a9a8f8c13db6c81ce9bd2ea9cbf47d1f79139b0 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Sun, 13 Jan 2019 13:31:02 -0800 Subject: [PATCH 07/20] 782 pt 1 and 2 --- cmd.txt | 510 ++++++++++++++++++ libraries/app/api.cpp | 45 +- libraries/app/application.cpp | 42 +- libraries/app/application_impl.hxx | 2 +- libraries/app/include/graphene/app/api.hpp | 7 +- .../app/include/graphene/app/application.hpp | 9 +- tests/common/database_fixture.cpp | 44 +- tests/tests/asset_api_tests.cpp | 22 +- tests/tests/group_order_api_tests.cpp | 67 +++ tests/tests/history_api_tests.cpp | 108 +++- 10 files changed, 811 insertions(+), 45 deletions(-) create mode 100644 cmd.txt create mode 100644 tests/tests/group_order_api_tests.cpp diff --git a/cmd.txt b/cmd.txt new file mode 100644 index 0000000000..dfd4551cd2 --- /dev/null +++ b/cmd.txt @@ -0,0 +1,510 @@ + 1 sudo gedit witness_node + 2 cd btscore/ + 3 git clone https://github.com/bitshares/bitshares-core.git develop + 4 apt get install git + 5 apt install git + 6 sudo apt install git + 7 sudo apt-get install git + 8 apt-get install git-core + 9 sudo apt-get install git-core + 10 sudo + 11 apt-get update + 12 sudo apt-get update + 13 sudo apt-get install git-core + 14 sudo git clone https://github.com/bitshares/bitshares-core.git develop + 15 sudo apt-get update + 16 sudo apt-get install autoconf cmake make automake libtool git libboost-all-dev libssl-dev g++ libcurl4-openssl-dev + 17 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo + 18 ls + 19 cd develop/ + 20 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo + 21 sudo cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo + 22 git submodule update --init --recursive + 23 sudo git submodule update --init --recursive + 24 sudo cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo + 25 makr + 26 make + 27 sudo make + 28 sudo apt-get install gedit + 29 sudo gedit config.ini + 30 cd .. + 31 ./programs/witness_node/witness_node + 32 sudo ./programs/witness_node/witness_node + 33 sudo code + 34 sudo + 35 ls + 36 code + 37 sudo snap install vscode + 38 sudo snap install vscode --classic + 39 sudo grub-install. + 40 sudo grub-install + 41 sudo apt install curl + 42 sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/JackHack96/dell-xps-9570-ubuntu-respin/master/xps-tweaks.sh)" + 43 g++ -version + 44 udo apt install g++ + 45 sudo apt install g++ + 46 sudo apt install build-essential + 47 g++ --version + 48 sudo gedit /usr/share/X11/xorg.conf.d/*synaptics-quirks.conf + 49 sudo prime-select nvidia + 50 sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/JackHack96/dell-xps-9570-ubuntu-respin/master/xps-tweaks.sh)" + 51 sudo prime-select intel + 52 git clone git@github.com:mtompkins/linux-kernel-utilities.git + 53 git clone manikey123@github.com:mtompkins/linux-kernel-utilities.git + 54 git clone git@github.com:mtompkins/linux-kernel-utilities.git + 55 git clone https://github.com/mtompkins/linux-kernel-utilities.git + 56 cd linux-kernel-utilities + 57 chmod 750 *.sh + 58 sudo dpkg -i linux-kernel-utilities*.deb + 59 sudo ./update_ubuntu_kernel.sh + 60 clear + 61 sudo ./update_ubuntu_kernel.sh + 62 sudo apt-get install xserver-xorg-input-libinput + 63 sudo apt-get remove --purge xserver-xorg-input-synaptics + 64 sudo apt install update + 65 sudo apt install tlp tlp-rdw powert + 66 sudo apt install tlp tlp-rdw powertop + 67 sudo tlp start + 68 sudo powertop --auto-tune + 69 sudo reboot + 70 ls + 71 sudo tar -xvf btsclonenov17_z.zip + 72 sudo tar -xvf {btsclonenov17_z.zip} + 73 sudo unzip btsclonenov17_z.zip + 74 cd btsclonenov17/ + 75 ls + 76 cd devlope + 77 cd devlop + 78 cd develop/ + 79 nom start + 80 npm start + 81 sudo apt install npm + 82 npm start + 83 curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - + 84 sudo apt-get install -y nodejs + 85 curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - + 86 curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list + 87 npm start + 88 sudo npm start + 89 sudo npm uninstall + 90 sudo npm install + 91 sudo npm start + 92 sudo gedit /home/reddell/.npm/_logs/2018-11-18T01_59_16_750Z-debug.log + 93 npm install reinstall + 94 sudo npm install reinstall + 95 sudo npm start + 96 sudo npm install cross-env@latest --save-dev + 97 sudo npm start + 98 sudo npm rebuild node-sass + 99 cd bin + 100 ls + 101 ./clion.sh + 102 mkdir + 103 pwd + 104 mkdir btsui + 105 cd btsui + 106 git clone https://github.com/bitshares/bitshares-ui.git develop + 107 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash + 108 nvm install v9 + 109 sudo apt install nvm + 110 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash + 111 unzip app.zip + 112 nvm install v9 + 113 nvm use v9 + 114 pwd + 115 ls + 116 cd Desktop/ + 117 ls + 118 cd .. + 119 cd btsui + 120 ls + 121 cd develop + 122 ls + 123 npm install + 124 npm start + 125 git checkout -b 2084-search-fix + 126 git commit -m "2084-issue-search-fix" + 127 git config user.email "mansiimohan@gmail.com" + 128 git config --global user.n" + 129 git config user.name "manikey123" + 130 git commit -m "2084-issue-search-fix" + 131 git push origin 2084-search-fix + 132 git config --global user.email "mansiimohan@gmail.com" + 133 git config --global user.name "manikey123" + 134 git push origin 2084-search-fix + 135 git checkout -b 2084-search-fix1 + 136 git commit -m "2084-issue-search-fix1" + 137 git push origin 2084-search-fix1 + 138 cd app/ + 139 ls + 140 git commit -m "2084-issue-search-fix1" + 141 cd .. + 142 cd .. + 143 git clone https://github.com/bitshares/bitshares-ui.git develop + 144 rm -rf + 145 git clone https://github.com/bitshares/bitshares-ui.git develop + 146 rm -r develop + 147 git clone https://github.com/bitshares/bitshares-ui.git develop + 148 git checkout -b 2084-search-fix2 + 149 cd develop + 150 cd app + 151 git checkout -b 2084-search-fix2 + 152 cd .. + 153 git clone https://github.com/bitshares/bitshares-ui.git develop + 154 git checkout -b 2084-search-fix5 + 155 cd develop + 156 git checkout -b 2084-search-fix5 + 157 git commit -m "2084-issue-search-fix5" + 158 git add . + 159 git commit -m "2084-issue-search-fix5" + 160 git push origin 2084-search-fix5 + 161 git config user.name + 162 git config email + 163 git config user.email + 164 git push origin 2084-search-fix5 + 165 cd .. + 166 git clone git@github.com:bitshares/bitshares-ui.git + 167 git clone manikey123@github.com:bitshares/bitshares-ui.git develop + 168 git checkout -b 2084-search-fix-m1 + 169 cd develop + 170 git checkout -b 2084-search-fix-m1 + 171 git add . + 172 git commit -m "2084-issue-search-fix-m1" + 173 git push origin 2084-search-fix5-m1 + 174 git push origin 2084-search-fix-m1 + 175 history + 176 cd .. + 177 git clone manikey123@github.com:bitshares/bitshares-ui.git develop + 178 git clone https://github.com/manikey123/bitshares-ui.git + 179 git clone https://github.com/manikey123/bitshares-ui.git develop + 180 git checkout -b 2084-search-fix-m2 + 181 cd develop/ + 182 git checkout -b 2084-search-fix-m2 + 183 git add . + 184 git commit -m "2084-issue-search-fix-m2" + 185 git add . + 186 git commit -m "2084-issue-search-fix-m2" + 187 cd .. + 188 cd develop + 189 git add . + 190 cd .. + 191 git clone https://github.com/manikey123/bitshares-ui.git develop + 192 cd .. + 193 mkdir btsabc + 194 cd btsabc + 195 git clone https://github.com/manikey123/bitshares-ui.git develop + 196 cd develop + 197 git checkout -b 2084-search-fix-f1 + 198 git add . + 199 git commit -m "2084-issue-search-fix-f1" + 200 git push origin 2084-search-fix-f1 + 201 sudo apt install net-tools + 202 netstat -ltnp + 203 git clone https://github.com/cc32d9/eos.watchdoggiee.git + 204 pwd + 205 cd eos.watchdoggiee/ + 206 make install + 207 ls + 208 sudo make + 209 LNODEOS -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 210 echo $SHELL + 211 lnodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 212 source ~/.bashrc + 213 lnodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 214 lnodeos nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 215 source ~/.bashrc + 216 lnodeos nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 217 lnodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 218 ~/.bash_profile + 219 cd ~ + 220 sudo ~/.bash_profile + 221 pwd + 222 vi ~/.bash_profile + 223 cd ~ + 224 ls + 225 cd / + 226 ls + 227 cd root + 228 cd sudo root + 229 sudo cd root + 230 sudo su + 231 cd ~ + 232 ~/.profile + 233 sudo vi ~/.profile + 234 sudo vi ~/.bashrc + 235 sudo vim ~/.bashrc + 236 sudo vi ~/.bashrc + 237 cd /home/reddell/Desktop/eoscontracts/eos/build/programs/cleos + 238 cleos wallet create --name treasure + 239 ./cleos wallet create --name treasure + 240 cleos + 241 cleos wallet create --name treasure + 242 cleos wallet create --name treasure --to-console + 243 git clone https://github.com/EOSIO/eos --recursive + 244 cd eos + 245 ./eosio_build.sh + 246 sudo nano /etc/apt/sources.list.d/yarn.list + 247 sudo gedit /etc/apt/sources.list.d/yarn.list + 248 sudo rm /etc/apt/sources.list.d/yarn.list + 249 sudo apt update + 250 sudo ./eosio_build.sh + 251 sudo apt-get install meld + 252 ./eosio_install.sh + 253 sudo ./eosio_install.sh + 254 ls + 255 make install + 256 cd build + 257 make + 258 make install + 259 sudo make install + 260 cd programs + 261 cd nodeeos + 262 cd nodeos/ + 263 clear + 264 nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 265 hitory + 266 history + 267 pwd + 268 nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin + 269 mkdir btscore786 + 270 cd btscore786/ + 271 git clone -b develop https://github.com/manikey123/bitshares-core.git + 272 ls + 273 cd bitshares-core/ + 274 ls + 275 sudo apt-get update + 276 sudo apt-get install autoconf cmake make automake libtool git libboost-all-dev libssl-dev g++ libcurl4-openssl-dev + 277 make + 278 ls + 279 cmake -DCMAKE_BUILD_TYPE=Release . + 280 git submodule update --init --recursive + 281 cmake -DCMAKE_BUILD_TYPE=Release + 282 make + 283 BOOST_ROOT=$HOME/opt/boost_1_57_0 + 284 sudo apt-get update + 285 sudo apt-get install autotools-dev build-essential libbz2-dev libicu-dev python-dev + 286 wget -c 'http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.bz2/download' -O boost_1_57_0.tar.bz2 + 287 [ $( sha256sum boost_1_57_0.tar.bz2 | cut -d ' ' -f 1 ) == "910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967" ] || ( echo 'Corrupt download' ; exit 1 ) + 288 ./bootstrap.sh "--prefix=$BOOST_ROOT" + 289 cd boost_1_57_0/ + 290 [ $( sha256sum boost_1_57_0.tar.bz2 | cut -d ' ' -f 1 ) == "910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967" ] || ( echo 'Corrupt download' ; exit 1 ) + 291 tar xjf boost_1_57_0.tar.bz2 + 292 cd boost_1_57_0/ + 293 ./bootstrap.sh "--prefix=$BOOST_ROOT" + 294 ./b2 install + 295 ./b2 install >isssue.txt + 296 sudo gedit isssue.txt + 297 sudo ./b2 install >isssue.txt + 298 sudo ./b2 install + 299 ./programs/witness_node/witness_node + 300 ls + 301 cd.. + 302 cd .. + 303 ./programs/witness_node/witness_node + 304 curl -s https://updates.signal.org/desktop/apt/keys.asc | sudo apt-key add - + 305 echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list + 306 sudo apt update && sudo apt install signal-desktop + 307 sudo apt install snapd + 308 sudo snap install signal-desktop + 309 sudo signal-dekstop + 310 sudo signal + 311 whereis signal + 312 which signal + 313 sudo apt update && sudo apt install signal-desktop + 314 sudo apt uninstall signal-desktop + 315 sudo apt install nautilus-admin + 316 sudo nautilus -q + 317 sudo apt-get install dconf-editor + 318 gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top true + 319 sudo apt-get install xdotool wmctrl + 320 xdotool %l + 321 sudo signal-desktop + 322 sudo ubuntu-software + 323 mkdir github_folder + 324 cd github_folder/ + 325 mkdir project_bts + 326 cd project_bts/ + 327 git clone https://github.com/manikey123/bitshares-core.git + 328 cd .. + 329 rm -r + 330 rm -rf project_bts/ + 331 ls + 332 mkdir project_bts + 333 cd project_bts/ + 334 ls + 335 git clone -b develophttps://github.com/manikey123/bitshares-core.git + 336 git clone -b develop https://github.com/manikey123/bitshares-core.git + 337 sudo apt-get install meld + 338 cd bitshares-core/ + 339 git checkout -b 782-part1 + 340 git commit -m "782-part1" + 341 git add . + 342 git commit -m "782-part1" + 343 git push origin 782-part1 + 344 sudo apt install wine64 + 345 wine --version + 346 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2] + 347 ], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq + 348 sudo apt install jq + 349 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2] + 350 ], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq + 351 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2] + 352 ], "method": "call", "id": 10}' --silent http://localhost:8090/rpc + 353 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq + 354 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc + 355 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:8090 + 356 netstat --listen + 357 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 + 358 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 >>a.txt + 359 sudo gedit a.txt + 360 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq + 361 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 >>a.txt + 362 sudo gedit a.txt + 363 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 + 364 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq + 365 netstat --listen + 366 netstat --listen | gerp '8090' + 367 netstat --listen | grep '8090' + 368 npm install -g wscat + 369 sudo npm install -g wscat + 370 npm install -g npm + 371 sudo npm install -g npm + 372 wscat -c ws://127.0.0.1:8090 + 373 curl --data '{"jsonrpc": "2.0", "method": "get_accounts", "params": [["1.2.0"]], "id": 1}' http://127.0.0.1:8090/rpc + 374 cd cd /opt/Citrix/ICAClient/keystore/ + 375 cd /opt/Citrix/ICAClient/keystore/ + 376 ./witness_node + 377 cd .. + 378 sudo rm -rf btsclonenov17 + 379 sudo ufw status + 380 sudo apt install gufw + 381 netstat -l | grep '8090' + 382 netstat --listen | grep '8090' + 383 netstat --listen + 384 ls + 385 cd btscore786/ + 386 ls + 387 cd bitshares-core/ + 388 wget https://status200.bitshares.apasia.tech/downloads/bts-node-full.tar.gz | sed 's/\r//g' + 389 ls + 390 rm -rf bts-node-full.tar.gz + 391 wget https://status200.bitshares.apasia.tech/downloads/bts-node-full.tar.gz | sed 's/\r//g' + 392 sudo rm -rf develop/ + 393 sudo rm -rf eoscontracts + 394 ./programs/witness_node + 395 ./programs/witness_node/witness_node + 396 sudo blkid + 397 gdisk -l /dev/sda + 398 sudo su + 399 tar zxvf bts-node-full.tar.gz -C ~/btscore786/bitshares-core/program + 400 cd ~/btscore786/bitshares-core/program + 401 cd ~/ + 402 cd btscore786/ + 403 cd .. + 404 sudo tar zxvf bts-node-full.tar.gz -C ~/btscore786/bitshares-core/program + 405 cd /media/reddell/My Passport + 406 cd / + 407 cd /media/reddell/My Passport + 408 cd ~ + 409 cd / + 410 ls + 411 cd home/reddell + 412 cd btscore786/ + 413 sudo tar zxvf bts-node-full.tar.gz -C ~/btscore786/bitshares-core/program + 414 sudo tar zxvf bts-node-full.tar.gz -C /btscore786/bitshares-core/program + 415 rm -rf blockchain/ + 416 sudo tar zxvf bts-node-full.tar.gz + 417 tar zxvf bts-node-full.tar.gz + 418 cd journal/ + 419 rm -rf 5af26029898f4c1fba2870fc538af79c/ + 420 sudo rm -rf 5af26029898f4c1fba2870fc538af79c/ + 421 rm -rf blockchain/ + 422 cd btscore786/ + 423 ls + 424 cd bitshares-core/ + 425 wget https://status200.bitshares.apasia.tech/downloads/bts-node-full.tar.gz | sed 's/\r//g' + 426 ls + 427 cd install + 428 cd programs + 429 ls + 430 cd witness_node/ + 431 ls + 432 ./witness_node + 433 Y + 434 ./witness_node + 435 ./witness_node --replay-blockchain + 436 tar zxvf bts-node-full.tar.gz + 437 netsat --listen | grep '8090' + 438 n + 439 cd bitshares-core/ + 440 git pull + 441 git pull develop + 442 cd .. + 443 rm -rf bitshares-core/ + 444 git clone -b develop https://github.com/bitshares/bitshares-core.git + 445 cd bitshares-core/ + 446 git submodule update --init --recursive + 447 sudo gedit config.ini + 448 cd / + 449 cd ~ + 450 sudo apt-get install openvpn + 451 sudo apt-get install openvpn network-manager-openvpn network-manager-openvpn-gnome + 452 cd /tmp/graphene-tmp/ + 453 ls + 454 sudo 962d-abf0-9900-1c34/ + 455 cd 962d-abf0-9900-1c34/ + 456 ls + 457 cd blockchain/ + 458 ls + 459 cd .. + 460 cd 7da6-1a00-0b11-9d3e/ + 461 ls + 462 sudo ./clion.sh + 463 cd.. + 464 cd .. + 465 sudo cd VPNBook.com-OpenVPN-FR1/ + 466 vi history_api_tests.cpp + 467 vim history_api_tests.cpp + 468 sudo apt-get install vim + 469 vim history_api_tests.cpp + 470 sudo apt-get install doxygen + 471 cd /tmp/ + 472 ls + 473 cd graphene-tmp/ + 474 ls + 475 clear + 476 ls + 477 cd 15e3-5f1e-ad93-53b8/ + 478 ls + 479 gedit config.ini + 480 cd .. + 481 ls + 482 cd 58e7-d6d0-7c69-f537/ + 483 cd .. + 484 cd rm -rf graphene-tmp/ + 485 sudo rm -rf graphene-tmp/ + 486 cd graphene-tmp/ + 487 ls + 488 cd 55ba-b8fc-221d-c793/ + 489 ls + 490 cd .. + 491 cd 90ca-f4e8-134d-ff97/ + 492 ls + 493 sudo gedit config.ini + 494 cd .. + 495 ls + 496 cd .. + 497 rm -rf graphene-tmp/ + 498 sudo rm -rf graphene-tmp/ + 499 git add . + 500 git push origin 782_test_p1 + 501 git pull + 502 git push origin 782_test_p1 + 503 git add . + 504 git commit -m "updated based on review comment received" + 505 git push origin 782_test_p1 + 506 git pull origin 782_test_p1 + 507 git add . + 508 git commit -m "updated based on review comment received1" + 509 git push origin 782_test_p1 + 510 history> cmd.txt diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 5a35bc8019..142b5153c2 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -101,7 +101,7 @@ namespace graphene { namespace app { } else if( api_name == "asset_api" ) { - _asset_api = std::make_shared< asset_api >( std::ref( *_app.chain_database() ) ); + _asset_api = std::make_shared< asset_api >( std::ref( _app ) ); } else if( api_name == "orders_api" ) { @@ -316,7 +316,8 @@ namespace graphene { namespace app { { FC_ASSERT( _app.chain_database() ); const auto& db = *_app.chain_database(); - FC_ASSERT( limit <= 100 ); + uint64_t api_limit_get_account_history=_app.get_options().api_limit_get_account_history; + FC_ASSERT( limit <= api_limit_get_account_history ); vector result; account_id_type account; try { @@ -352,8 +353,8 @@ namespace graphene { namespace app { { FC_ASSERT( _app.chain_database() ); const auto& db = *_app.chain_database(); - uint64_t max_account_history_operations_limit=_app.get_options().max_account_history_operations_limit; - FC_ASSERT(limit <= max_account_history_operations_limit); + uint64_t api_limit_get_account_history_operations=_app.get_options().api_limit_get_account_history_operations; + FC_ASSERT(limit <= api_limit_get_account_history_operations); vector result; account_id_type account; try { @@ -392,7 +393,8 @@ namespace graphene { namespace app { { FC_ASSERT( _app.chain_database() ); const auto& db = *_app.chain_database(); - FC_ASSERT(limit <= 100); + uint64_t api_limit_get_relative_account_history=_app.get_options().api_limit_get_relative_account_history; + FC_ASSERT(limit <= api_limit_get_relative_account_history); vector result; account_id_type account; try { @@ -431,7 +433,8 @@ namespace graphene { namespace app { history_operation_detail history_api::get_account_history_by_operations(const std::string account_id_or_name, vector operation_types, uint32_t start, unsigned limit) { - FC_ASSERT(limit <= 100); + uint64_t api_limit_get_account_history_by_operations=_app.get_options().api_limit_get_account_history_by_operations; + FC_ASSERT(limit <= api_limit_get_account_history_by_operations); history_operation_detail result; vector objs = get_relative_account_history(account_id_or_name, start, limit, limit + start - 1); std::for_each(objs.begin(), objs.end(), [&](const operation_history_object &o) { @@ -527,13 +530,14 @@ namespace graphene { namespace app { } // asset_api - asset_api::asset_api(graphene::chain::database& db) : _db(db) { } - asset_api::~asset_api() { } - vector asset_api::get_asset_holders( asset_id_type asset_id, uint32_t start, uint32_t limit ) const { - FC_ASSERT(limit <= 100); - const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + FC_ASSERT( _app.chain_database() ); + const auto& db = *_app.chain_database(); + uint64_t api_limit_get_asset_holders=_app.get_options().api_limit_get_asset_holders; + + FC_ASSERT(limit <= api_limit_get_asset_holders); + const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); vector result; @@ -550,7 +554,7 @@ namespace graphene { namespace app { if( index++ < start ) continue; - const auto account = _db.find(bal.owner); + const auto account = db.find(bal.owner); account_asset_balance aab; aab.name = account->name; @@ -564,8 +568,9 @@ namespace graphene { namespace app { } // get number of asset holders. int asset_api::get_asset_holders_count( asset_id_type asset_id ) const { - - const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + FC_ASSERT( _app.chain_database() ); + const auto& db = *_app.chain_database(); + const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); int count = boost::distance(range) - 1; @@ -574,18 +579,19 @@ namespace graphene { namespace app { } // function to get vector of system assets with holders count. vector asset_api::get_all_asset_holders() const { - + FC_ASSERT( _app.chain_database() ); + const auto& db = *_app.chain_database(); vector result; vector total_assets; - for( const asset_object& asset_obj : _db.get_index_type().indices() ) + for( const asset_object& asset_obj : db.get_index_type().indices() ) { - const auto& dasset_obj = asset_obj.dynamic_asset_data_id(_db); + const auto& dasset_obj = asset_obj.dynamic_asset_data_id(db); asset_id_type asset_id; asset_id = dasset_obj.id; - const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); int count = boost::distance(range) - 1; @@ -614,7 +620,8 @@ namespace graphene { namespace app { optional start, uint32_t limit )const { - FC_ASSERT( limit <= 101 ); + uint64_t api_limit_get_grouped_limit_orders=_app.get_options().api_limit_get_grouped_limit_orders; + FC_ASSERT( limit <= api_limit_get_grouped_limit_orders ); auto plugin = _app.get_plugin( "grouped_orders" ); FC_ASSERT( plugin ); const auto& limit_groups = plugin->limit_order_groups(); diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 18826a1dd3..e33731d492 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -319,10 +319,26 @@ void application_impl::set_dbg_init_key( graphene::chain::genesis_state_type& ge } -void application_impl::set_dgb_max_acct_history_opt_limit() { - if (_options->count("max-account-history-operations-limit")) { - _app_options.max_account_history_operations_limit = _options->at("max-account-history-operations-limit").as(); +void application_impl::set_dgb_api_limit_api() { + if (_options->count("api-limit-get-account-history-operations")) { + _app_options.api_limit_get_account_history_operations = _options->at("api-limit-get-account-history-operations").as(); } + if(_options->count("api-limit-get-account-history")){ + _app_options.api_limit_get_account_history = _options->at("api-limit-get-account-history").as(); + } + if(_options->count("api-limit-get-grouped-limit-orders")){ + _app_options.api_limit_get_grouped_limit_orders = _options->at("api-limit-get-grouped-limit-orders").as(); + } + if(_options->count("api-limit-get-relative-account-history")){ + _app_options.api_limit_get_relative_account_history = _options->at("api-limit-get-relative-account-history").as(); + } + if(_options->count("api-limit-get-account-history-by-operations")){ + _app_options.api_limit_get_account_history_by_operations = _options->at("api-limit-get-account-history-by-operations").as(); + } + if(_options->count("api-limit-get-asset-holders")){ + _app_options.api_limit_get_asset_holders = _options->at("api-limit-get-asset-holders").as(); + } + } void application_impl::startup() @@ -446,7 +462,7 @@ void application_impl::startup() if ( _options->count("enable-subscribe-to-all") ) _app_options.enable_subscribe_to_all = _options->at( "enable-subscribe-to-all" ).as(); - set_dgb_max_acct_history_opt_limit(); + set_dgb_api_limit_api(); if( _active_plugins.find( "market_history" ) != _active_plugins.end() ) _app_options.has_market_history_plugin = true; @@ -991,8 +1007,18 @@ void application::set_program_options(boost::program_options::options_descriptio ("enable-standby-votes-tracking", bpo::value()->implicit_value(true), "Whether to enable tracking of votes of standby witnesses and committee members. " "Set it to true to provide accurate data to API clients, set to false for slightly better performance.") - ("max-account-history-operations-limit",boost::program_options::value()->default_value(100), - "for history_api::get_account_history_operations to set its limit value default ass 100") + ("api-limit-get-account-history-operations",boost::program_options::value()->default_value(100), + "For history_api::get_account_history_operations to set its default limit value as 100") + ("api-limit-get-account-history",boost::program_options::value()->default_value(100), + "For history_api::get_account_history to set its default limit value as 100") + ("api-limit-get-grouped-limit-orders",boost::program_options::value()->default_value(101), + "For orders_api::get_grouped_limit_orders to set its default limit value as 101") + ("api-limit-get-relative-account-history",boost::program_options::value()->default_value(100), + "For history_api::get_relative_account_history to set its default limit value as 100") + ("api-limit-get-account-history-by-operations",boost::program_options::value()->default_value(100), + "For history_api::get_account_history_by_operations to set its default limit value as 100") + ("api-limit-get-asset-holders",boost::program_options::value()->default_value(100), + "For asset_api::get_asset_holders to set its default limit value as 100") ; command_line_options.add(configuration_file_options); command_line_options.add_options() @@ -1087,10 +1113,10 @@ void application::startup() throw; } } -void application::set_dgb_max_acct_history_opt_limit() +void application::set_dgb_api_limit_api() { try { - my->set_dgb_max_acct_history_opt_limit(); + my->set_dgb_api_limit_api(); } catch ( const fc::exception& e ) { elog( "${e}", ("e",e.to_detail_string()) ); throw; diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index bda0377637..7539b71065 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -41,7 +41,7 @@ class application_impl : public net::node_delegate } void set_dbg_init_key( graphene::chain::genesis_state_type& genesis, const std::string& init_key ); - void set_dgb_max_acct_history_opt_limit(); + void set_dgb_api_limit_api(); void startup(); diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index af34bbaf73..258391a942 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -438,8 +438,8 @@ namespace graphene { namespace app { class asset_api { public: - asset_api(graphene::chain::database& db); - ~asset_api(); + asset_api(application& app) + :_app(app), database_api( std::ref(*app.chain_database()), &(app.get_options())) {} /** * @brief Get asset holders for a specific asset @@ -464,7 +464,8 @@ namespace graphene { namespace app { vector get_all_asset_holders() const; private: - graphene::chain::database& _db; + application& _app; + graphene::app::database_api database_api; }; /** diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 4cb26d9186..13f507b1b0 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -40,7 +40,12 @@ namespace graphene { namespace app { public: bool enable_subscribe_to_all = false; bool has_market_history_plugin = false; - uint64_t max_account_history_operations_limit=100; + uint64_t api_limit_get_account_history_operations=100; + uint64_t api_limit_get_account_history=100; + uint64_t api_limit_get_grouped_limit_orders=101; + uint64_t api_limit_get_relative_account_history=100; + uint64_t api_limit_get_account_history_by_operations=100; + uint64_t api_limit_get_asset_holders=100; }; class application @@ -88,7 +93,7 @@ namespace graphene { namespace app { net::node_ptr p2p_node(); std::shared_ptr chain_database()const; - void set_dgb_max_acct_history_opt_limit(); + void set_dgb_api_limit_api(); void set_block_production(bool producing_blocks); fc::optional< api_access_info > get_api_access_info( const string& username )const; void set_api_access_info(const string& username, api_access_info&& permissions); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index fe21366958..d82fa773c3 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -120,12 +120,40 @@ database_fixture::database_fixture() { options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)75, false))); } - if (current_test_name == "setting_max_operation_limit_get_account_history_operations") + if (current_test_name == "api_limit_get_account_history_operations") { options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); - options.insert(std::make_pair("max-account-history-operations-limit", boost::program_options::variable_value((uint64_t)300, false))); + options.insert(std::make_pair("api-limit-get-account-history-operations", boost::program_options::variable_value((uint64_t)300, false))); options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } + if(current_test_name =="api_limit_get_account_history") + { + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); + options.insert(std::make_pair("api-limit-get-account-history", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + if(current_test_name =="api_limit_get_grouped_limit_orders") + { + options.insert(std::make_pair("api-limit-get-grouped-limit-orders", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("grouped_orders"), false))); + } + if(current_test_name =="api_limit_get_relative_account_history") + { + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); + options.insert(std::make_pair("api-limit-get-relative-account-history", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + if(current_test_name =="api_limit_get_account_history_by_operations") + { + options.insert(std::make_pair("api-limit-get-account-history-by-operations", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + if(current_test_name =="api_limit_get_asset_holders") + { + options.insert(std::make_pair("api-limit-get-asset-holders", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + // add account tracking for ahplugin for special test case with track-account enabled if( !options.count("track-account") && current_test_name == "track_account") { std::vector track_account; @@ -167,11 +195,13 @@ database_fixture::database_fixture() ahplugin->plugin_set_app(&app); ahplugin->plugin_initialize(options); ahplugin->plugin_startup(); - if (current_test_name == "setting_max_operation_limit_get_account_history_operations") - { - app.initialize(graphene::utilities::temp_directory_path(), options); - app.set_dgb_max_acct_history_opt_limit(); - } + if (current_test_name == "api_limit_get_account_history_operations" || current_test_name == "api_limit_get_account_history" + || current_test_name == "api_limit_get_grouped_limit_orders" || current_test_name == "api_limit_get_relative_account_history" + || current_test_name == "api_limit_get_account_history_by_operations" || current_test_name =="api_limit_get_asset_holders") + { + app.initialize(graphene::utilities::temp_directory_path(), options); + app.set_dgb_api_limit_api(); + } } if(current_test_name == "elasticsearch_objects" || current_test_name == "elasticsearch_suite") { diff --git a/tests/tests/asset_api_tests.cpp b/tests/tests/asset_api_tests.cpp index aaa517a962..a4e12fd63d 100644 --- a/tests/tests/asset_api_tests.cpp +++ b/tests/tests/asset_api_tests.cpp @@ -37,7 +37,7 @@ BOOST_FIXTURE_TEST_SUITE(asset_api_tests, database_fixture) BOOST_AUTO_TEST_CASE( asset_holders ) { - graphene::app::asset_api asset_api(db); + graphene::app::asset_api asset_api(app); // create an asset and some accounts create_bitasset("USD", account_id_type()); @@ -60,5 +60,25 @@ BOOST_AUTO_TEST_CASE( asset_holders ) BOOST_CHECK(holders[2].name == "alice"); BOOST_CHECK(holders[3].name == "dan"); } +BOOST_AUTO_TEST_CASE( api_limit_get_asset_holders ) +{ + graphene::app::asset_api asset_api(app); + + // create an asset and some accounts + create_bitasset("USD", account_id_type()); + auto dan = create_account("dan"); + auto bob = create_account("bob"); + auto alice = create_account("alice"); + + // send them some bts + transfer(account_id_type()(db), dan, asset(100)); + transfer(account_id_type()(db), alice, asset(200)); + transfer(account_id_type()(db), bob, asset(300)); + + // make call + GRAPHENE_CHECK_THROW(asset_api.get_asset_holders(asset_id_type(), 0, 260), fc::exception) + vector holders = asset_api.get_asset_holders(asset_id_type(), 0, 210);; + BOOST_REQUIRE_EQUAL( holders.size(), 4 ); +} BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/group_order_api_tests.cpp b/tests/tests/group_order_api_tests.cpp new file mode 100644 index 0000000000..b12d34fb0c --- /dev/null +++ b/tests/tests/group_order_api_tests.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018 oxarbitrage, and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include +#include + +#include "../common/database_fixture.hpp" + +using namespace graphene::chain; +using namespace graphene::chain::test; +using namespace graphene::app; + +BOOST_FIXTURE_TEST_SUITE(grouped_orders_api_tests, database_fixture) + +BOOST_AUTO_TEST_CASE(api_limit_get_grouped_limit_orders) { + try { + graphene::app::orders_api orders_api(app); + optional< api_access_info > acc; + optional start; + + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + int asset_create_op_id = operation::tag::value; + int account_create_op_id = operation::tag::value; + + GRAPHENE_CHECK_THROW(orders_api.get_grouped_limit_orders(asset_id_type(), asset_id_type(),10, start,260), fc::exception) + vector< limit_order_group > orders =orders_api.get_grouped_limit_orders(asset_id_type(), bit_jmj_id, 10,start,240); + BOOST_REQUIRE_EQUAL( orders.size(), 0); + + } catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } +} + + +BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 056023b4f2..5e303caa1c 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -590,14 +590,14 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { generate_block(); // history is set to limit transactions to 75 (see database_fixture.hpp) - // so asking for more should only return 75 (and not throw exception, + // so asking for more should only return 75 (and not throw exception, // see https://github.com/bitshares/bitshares-core/issues/1490 histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); BOOST_CHECK_EQUAL(histories.size(), 75); if (histories.size() > 0) BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - + } catch (fc::exception &e) { edump((e.to_detail_string())); @@ -605,7 +605,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { } } //new test case for increasing the limit based on the config file -BOOST_AUTO_TEST_CASE(setting_max_operation_limit_get_account_history_operations) { +BOOST_AUTO_TEST_CASE(api_limit_get_account_history_operations) { try { graphene::app::history_api hist_api(app); @@ -664,11 +664,111 @@ BOOST_AUTO_TEST_CASE(setting_max_operation_limit_get_account_history_operations) // see https://github.com/bitshares/bitshares-core/issues/1490 GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type() ,operation_history_id_type(), 301), fc::exception) histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); } catch (fc::exception &e) { edump((e.to_detail_string())); throw; } } +BOOST_AUTO_TEST_CASE(api_limit_get_account_history) { + try { + graphene::app::history_api hist_api(app); + + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + int asset_create_op_id = operation::tag::value; + int account_create_op_id = operation::tag::value; + //account_id_type() did 3 ops and includes id0 + vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); + + BOOST_CHECK_EQUAL(histories.size(), 3); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); + + // 1 account_create op larger than id1 + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 210, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK(histories[0].id.instance() != 0); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + + // Limit 2 returns 2 result + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK(histories[1].id.instance() != 0); + BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); + // bob has 1 op + histories = hist_api.get_account_history("bob", operation_history_id_type(), 210, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // create a bunch of accounts + for(int i = 0; i < 126; ++i) + { + std::string acct_name = "mytempacct" + std::to_string(i); + create_account(acct_name); + } + generate_block(); + + GRAPHENE_CHECK_THROW(hist_api.get_account_history("1.2.0", operation_history_id_type(), 260, operation_history_id_type()), fc::exception) + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + + } catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } +} +BOOST_AUTO_TEST_CASE(api_limit_get_relative_account_history) { + try { + graphene::app::history_api hist_api(app); + + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + GRAPHENE_CHECK_THROW(hist_api.get_relative_account_history("1.2.0", 126, 260, 0), fc::exception) + vector histories = hist_api.get_relative_account_history("1.2.0", 126, 210, 0); + BOOST_REQUIRE_EQUAL( histories.size(), 0 ); + + } catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } +} + +BOOST_AUTO_TEST_CASE(api_limit_get_account_history_by_operations) { + try { + graphene::app::history_api hist_api(app); + vector operation_types; + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + GRAPHENE_CHECK_THROW(hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 260), fc::exception) + history_operation_detail histories = hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 210); + BOOST_REQUIRE_EQUAL( histories.total_count, 0 ); + + } catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } +} + + BOOST_AUTO_TEST_SUITE_END() From 3aecf1f9fd9f51784e74ea6455199af1c803a32b Mon Sep 17 00:00:00 2001 From: manikey123 Date: Sun, 13 Jan 2019 13:34:55 -0800 Subject: [PATCH 08/20] 782 pt 1 and 2 edit --- cmd.txt | 510 -------------------------------------------------------- 1 file changed, 510 deletions(-) delete mode 100644 cmd.txt diff --git a/cmd.txt b/cmd.txt deleted file mode 100644 index dfd4551cd2..0000000000 --- a/cmd.txt +++ /dev/null @@ -1,510 +0,0 @@ - 1 sudo gedit witness_node - 2 cd btscore/ - 3 git clone https://github.com/bitshares/bitshares-core.git develop - 4 apt get install git - 5 apt install git - 6 sudo apt install git - 7 sudo apt-get install git - 8 apt-get install git-core - 9 sudo apt-get install git-core - 10 sudo - 11 apt-get update - 12 sudo apt-get update - 13 sudo apt-get install git-core - 14 sudo git clone https://github.com/bitshares/bitshares-core.git develop - 15 sudo apt-get update - 16 sudo apt-get install autoconf cmake make automake libtool git libboost-all-dev libssl-dev g++ libcurl4-openssl-dev - 17 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo - 18 ls - 19 cd develop/ - 20 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo - 21 sudo cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo - 22 git submodule update --init --recursive - 23 sudo git submodule update --init --recursive - 24 sudo cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo - 25 makr - 26 make - 27 sudo make - 28 sudo apt-get install gedit - 29 sudo gedit config.ini - 30 cd .. - 31 ./programs/witness_node/witness_node - 32 sudo ./programs/witness_node/witness_node - 33 sudo code - 34 sudo - 35 ls - 36 code - 37 sudo snap install vscode - 38 sudo snap install vscode --classic - 39 sudo grub-install. - 40 sudo grub-install - 41 sudo apt install curl - 42 sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/JackHack96/dell-xps-9570-ubuntu-respin/master/xps-tweaks.sh)" - 43 g++ -version - 44 udo apt install g++ - 45 sudo apt install g++ - 46 sudo apt install build-essential - 47 g++ --version - 48 sudo gedit /usr/share/X11/xorg.conf.d/*synaptics-quirks.conf - 49 sudo prime-select nvidia - 50 sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/JackHack96/dell-xps-9570-ubuntu-respin/master/xps-tweaks.sh)" - 51 sudo prime-select intel - 52 git clone git@github.com:mtompkins/linux-kernel-utilities.git - 53 git clone manikey123@github.com:mtompkins/linux-kernel-utilities.git - 54 git clone git@github.com:mtompkins/linux-kernel-utilities.git - 55 git clone https://github.com/mtompkins/linux-kernel-utilities.git - 56 cd linux-kernel-utilities - 57 chmod 750 *.sh - 58 sudo dpkg -i linux-kernel-utilities*.deb - 59 sudo ./update_ubuntu_kernel.sh - 60 clear - 61 sudo ./update_ubuntu_kernel.sh - 62 sudo apt-get install xserver-xorg-input-libinput - 63 sudo apt-get remove --purge xserver-xorg-input-synaptics - 64 sudo apt install update - 65 sudo apt install tlp tlp-rdw powert - 66 sudo apt install tlp tlp-rdw powertop - 67 sudo tlp start - 68 sudo powertop --auto-tune - 69 sudo reboot - 70 ls - 71 sudo tar -xvf btsclonenov17_z.zip - 72 sudo tar -xvf {btsclonenov17_z.zip} - 73 sudo unzip btsclonenov17_z.zip - 74 cd btsclonenov17/ - 75 ls - 76 cd devlope - 77 cd devlop - 78 cd develop/ - 79 nom start - 80 npm start - 81 sudo apt install npm - 82 npm start - 83 curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - - 84 sudo apt-get install -y nodejs - 85 curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - - 86 curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list - 87 npm start - 88 sudo npm start - 89 sudo npm uninstall - 90 sudo npm install - 91 sudo npm start - 92 sudo gedit /home/reddell/.npm/_logs/2018-11-18T01_59_16_750Z-debug.log - 93 npm install reinstall - 94 sudo npm install reinstall - 95 sudo npm start - 96 sudo npm install cross-env@latest --save-dev - 97 sudo npm start - 98 sudo npm rebuild node-sass - 99 cd bin - 100 ls - 101 ./clion.sh - 102 mkdir - 103 pwd - 104 mkdir btsui - 105 cd btsui - 106 git clone https://github.com/bitshares/bitshares-ui.git develop - 107 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash - 108 nvm install v9 - 109 sudo apt install nvm - 110 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash - 111 unzip app.zip - 112 nvm install v9 - 113 nvm use v9 - 114 pwd - 115 ls - 116 cd Desktop/ - 117 ls - 118 cd .. - 119 cd btsui - 120 ls - 121 cd develop - 122 ls - 123 npm install - 124 npm start - 125 git checkout -b 2084-search-fix - 126 git commit -m "2084-issue-search-fix" - 127 git config user.email "mansiimohan@gmail.com" - 128 git config --global user.n" - 129 git config user.name "manikey123" - 130 git commit -m "2084-issue-search-fix" - 131 git push origin 2084-search-fix - 132 git config --global user.email "mansiimohan@gmail.com" - 133 git config --global user.name "manikey123" - 134 git push origin 2084-search-fix - 135 git checkout -b 2084-search-fix1 - 136 git commit -m "2084-issue-search-fix1" - 137 git push origin 2084-search-fix1 - 138 cd app/ - 139 ls - 140 git commit -m "2084-issue-search-fix1" - 141 cd .. - 142 cd .. - 143 git clone https://github.com/bitshares/bitshares-ui.git develop - 144 rm -rf - 145 git clone https://github.com/bitshares/bitshares-ui.git develop - 146 rm -r develop - 147 git clone https://github.com/bitshares/bitshares-ui.git develop - 148 git checkout -b 2084-search-fix2 - 149 cd develop - 150 cd app - 151 git checkout -b 2084-search-fix2 - 152 cd .. - 153 git clone https://github.com/bitshares/bitshares-ui.git develop - 154 git checkout -b 2084-search-fix5 - 155 cd develop - 156 git checkout -b 2084-search-fix5 - 157 git commit -m "2084-issue-search-fix5" - 158 git add . - 159 git commit -m "2084-issue-search-fix5" - 160 git push origin 2084-search-fix5 - 161 git config user.name - 162 git config email - 163 git config user.email - 164 git push origin 2084-search-fix5 - 165 cd .. - 166 git clone git@github.com:bitshares/bitshares-ui.git - 167 git clone manikey123@github.com:bitshares/bitshares-ui.git develop - 168 git checkout -b 2084-search-fix-m1 - 169 cd develop - 170 git checkout -b 2084-search-fix-m1 - 171 git add . - 172 git commit -m "2084-issue-search-fix-m1" - 173 git push origin 2084-search-fix5-m1 - 174 git push origin 2084-search-fix-m1 - 175 history - 176 cd .. - 177 git clone manikey123@github.com:bitshares/bitshares-ui.git develop - 178 git clone https://github.com/manikey123/bitshares-ui.git - 179 git clone https://github.com/manikey123/bitshares-ui.git develop - 180 git checkout -b 2084-search-fix-m2 - 181 cd develop/ - 182 git checkout -b 2084-search-fix-m2 - 183 git add . - 184 git commit -m "2084-issue-search-fix-m2" - 185 git add . - 186 git commit -m "2084-issue-search-fix-m2" - 187 cd .. - 188 cd develop - 189 git add . - 190 cd .. - 191 git clone https://github.com/manikey123/bitshares-ui.git develop - 192 cd .. - 193 mkdir btsabc - 194 cd btsabc - 195 git clone https://github.com/manikey123/bitshares-ui.git develop - 196 cd develop - 197 git checkout -b 2084-search-fix-f1 - 198 git add . - 199 git commit -m "2084-issue-search-fix-f1" - 200 git push origin 2084-search-fix-f1 - 201 sudo apt install net-tools - 202 netstat -ltnp - 203 git clone https://github.com/cc32d9/eos.watchdoggiee.git - 204 pwd - 205 cd eos.watchdoggiee/ - 206 make install - 207 ls - 208 sudo make - 209 LNODEOS -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 210 echo $SHELL - 211 lnodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 212 source ~/.bashrc - 213 lnodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 214 lnodeos nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 215 source ~/.bashrc - 216 lnodeos nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 217 lnodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 218 ~/.bash_profile - 219 cd ~ - 220 sudo ~/.bash_profile - 221 pwd - 222 vi ~/.bash_profile - 223 cd ~ - 224 ls - 225 cd / - 226 ls - 227 cd root - 228 cd sudo root - 229 sudo cd root - 230 sudo su - 231 cd ~ - 232 ~/.profile - 233 sudo vi ~/.profile - 234 sudo vi ~/.bashrc - 235 sudo vim ~/.bashrc - 236 sudo vi ~/.bashrc - 237 cd /home/reddell/Desktop/eoscontracts/eos/build/programs/cleos - 238 cleos wallet create --name treasure - 239 ./cleos wallet create --name treasure - 240 cleos - 241 cleos wallet create --name treasure - 242 cleos wallet create --name treasure --to-console - 243 git clone https://github.com/EOSIO/eos --recursive - 244 cd eos - 245 ./eosio_build.sh - 246 sudo nano /etc/apt/sources.list.d/yarn.list - 247 sudo gedit /etc/apt/sources.list.d/yarn.list - 248 sudo rm /etc/apt/sources.list.d/yarn.list - 249 sudo apt update - 250 sudo ./eosio_build.sh - 251 sudo apt-get install meld - 252 ./eosio_install.sh - 253 sudo ./eosio_install.sh - 254 ls - 255 make install - 256 cd build - 257 make - 258 make install - 259 sudo make install - 260 cd programs - 261 cd nodeeos - 262 cd nodeos/ - 263 clear - 264 nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 265 hitory - 266 history - 267 pwd - 268 nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin - 269 mkdir btscore786 - 270 cd btscore786/ - 271 git clone -b develop https://github.com/manikey123/bitshares-core.git - 272 ls - 273 cd bitshares-core/ - 274 ls - 275 sudo apt-get update - 276 sudo apt-get install autoconf cmake make automake libtool git libboost-all-dev libssl-dev g++ libcurl4-openssl-dev - 277 make - 278 ls - 279 cmake -DCMAKE_BUILD_TYPE=Release . - 280 git submodule update --init --recursive - 281 cmake -DCMAKE_BUILD_TYPE=Release - 282 make - 283 BOOST_ROOT=$HOME/opt/boost_1_57_0 - 284 sudo apt-get update - 285 sudo apt-get install autotools-dev build-essential libbz2-dev libicu-dev python-dev - 286 wget -c 'http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.bz2/download' -O boost_1_57_0.tar.bz2 - 287 [ $( sha256sum boost_1_57_0.tar.bz2 | cut -d ' ' -f 1 ) == "910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967" ] || ( echo 'Corrupt download' ; exit 1 ) - 288 ./bootstrap.sh "--prefix=$BOOST_ROOT" - 289 cd boost_1_57_0/ - 290 [ $( sha256sum boost_1_57_0.tar.bz2 | cut -d ' ' -f 1 ) == "910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967" ] || ( echo 'Corrupt download' ; exit 1 ) - 291 tar xjf boost_1_57_0.tar.bz2 - 292 cd boost_1_57_0/ - 293 ./bootstrap.sh "--prefix=$BOOST_ROOT" - 294 ./b2 install - 295 ./b2 install >isssue.txt - 296 sudo gedit isssue.txt - 297 sudo ./b2 install >isssue.txt - 298 sudo ./b2 install - 299 ./programs/witness_node/witness_node - 300 ls - 301 cd.. - 302 cd .. - 303 ./programs/witness_node/witness_node - 304 curl -s https://updates.signal.org/desktop/apt/keys.asc | sudo apt-key add - - 305 echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list - 306 sudo apt update && sudo apt install signal-desktop - 307 sudo apt install snapd - 308 sudo snap install signal-desktop - 309 sudo signal-dekstop - 310 sudo signal - 311 whereis signal - 312 which signal - 313 sudo apt update && sudo apt install signal-desktop - 314 sudo apt uninstall signal-desktop - 315 sudo apt install nautilus-admin - 316 sudo nautilus -q - 317 sudo apt-get install dconf-editor - 318 gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top true - 319 sudo apt-get install xdotool wmctrl - 320 xdotool %l - 321 sudo signal-desktop - 322 sudo ubuntu-software - 323 mkdir github_folder - 324 cd github_folder/ - 325 mkdir project_bts - 326 cd project_bts/ - 327 git clone https://github.com/manikey123/bitshares-core.git - 328 cd .. - 329 rm -r - 330 rm -rf project_bts/ - 331 ls - 332 mkdir project_bts - 333 cd project_bts/ - 334 ls - 335 git clone -b develophttps://github.com/manikey123/bitshares-core.git - 336 git clone -b develop https://github.com/manikey123/bitshares-core.git - 337 sudo apt-get install meld - 338 cd bitshares-core/ - 339 git checkout -b 782-part1 - 340 git commit -m "782-part1" - 341 git add . - 342 git commit -m "782-part1" - 343 git push origin 782-part1 - 344 sudo apt install wine64 - 345 wine --version - 346 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2] - 347 ], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq - 348 sudo apt install jq - 349 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2] - 350 ], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq - 351 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2] - 352 ], "method": "call", "id": 10}' --silent http://localhost:8090/rpc - 353 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq - 354 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc - 355 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:8090 - 356 netstat --listen - 357 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 - 358 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 >>a.txt - 359 sudo gedit a.txt - 360 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq - 361 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 >>a.txt - 362 sudo gedit a.txt - 363 curl --data '{"id":0,"method":"get_recent_transaction_by_id","params":["42d8ff471d3693ecd6f8db17097ee3e3d9847591"]}' http://127.0.0.1:9050 - 364 curl --data '{"jsonrpc": "2.0", "params": ["database", "get_trade_history", ["1.3.0", "1.3.113", "2017-11-10T10:00:00", "2017-11-10T02:00:00", 2]], "method": "call", "id": 10}' --silent http://localhost:8090/rpc | jq - 365 netstat --listen - 366 netstat --listen | gerp '8090' - 367 netstat --listen | grep '8090' - 368 npm install -g wscat - 369 sudo npm install -g wscat - 370 npm install -g npm - 371 sudo npm install -g npm - 372 wscat -c ws://127.0.0.1:8090 - 373 curl --data '{"jsonrpc": "2.0", "method": "get_accounts", "params": [["1.2.0"]], "id": 1}' http://127.0.0.1:8090/rpc - 374 cd cd /opt/Citrix/ICAClient/keystore/ - 375 cd /opt/Citrix/ICAClient/keystore/ - 376 ./witness_node - 377 cd .. - 378 sudo rm -rf btsclonenov17 - 379 sudo ufw status - 380 sudo apt install gufw - 381 netstat -l | grep '8090' - 382 netstat --listen | grep '8090' - 383 netstat --listen - 384 ls - 385 cd btscore786/ - 386 ls - 387 cd bitshares-core/ - 388 wget https://status200.bitshares.apasia.tech/downloads/bts-node-full.tar.gz | sed 's/\r//g' - 389 ls - 390 rm -rf bts-node-full.tar.gz - 391 wget https://status200.bitshares.apasia.tech/downloads/bts-node-full.tar.gz | sed 's/\r//g' - 392 sudo rm -rf develop/ - 393 sudo rm -rf eoscontracts - 394 ./programs/witness_node - 395 ./programs/witness_node/witness_node - 396 sudo blkid - 397 gdisk -l /dev/sda - 398 sudo su - 399 tar zxvf bts-node-full.tar.gz -C ~/btscore786/bitshares-core/program - 400 cd ~/btscore786/bitshares-core/program - 401 cd ~/ - 402 cd btscore786/ - 403 cd .. - 404 sudo tar zxvf bts-node-full.tar.gz -C ~/btscore786/bitshares-core/program - 405 cd /media/reddell/My Passport - 406 cd / - 407 cd /media/reddell/My Passport - 408 cd ~ - 409 cd / - 410 ls - 411 cd home/reddell - 412 cd btscore786/ - 413 sudo tar zxvf bts-node-full.tar.gz -C ~/btscore786/bitshares-core/program - 414 sudo tar zxvf bts-node-full.tar.gz -C /btscore786/bitshares-core/program - 415 rm -rf blockchain/ - 416 sudo tar zxvf bts-node-full.tar.gz - 417 tar zxvf bts-node-full.tar.gz - 418 cd journal/ - 419 rm -rf 5af26029898f4c1fba2870fc538af79c/ - 420 sudo rm -rf 5af26029898f4c1fba2870fc538af79c/ - 421 rm -rf blockchain/ - 422 cd btscore786/ - 423 ls - 424 cd bitshares-core/ - 425 wget https://status200.bitshares.apasia.tech/downloads/bts-node-full.tar.gz | sed 's/\r//g' - 426 ls - 427 cd install - 428 cd programs - 429 ls - 430 cd witness_node/ - 431 ls - 432 ./witness_node - 433 Y - 434 ./witness_node - 435 ./witness_node --replay-blockchain - 436 tar zxvf bts-node-full.tar.gz - 437 netsat --listen | grep '8090' - 438 n - 439 cd bitshares-core/ - 440 git pull - 441 git pull develop - 442 cd .. - 443 rm -rf bitshares-core/ - 444 git clone -b develop https://github.com/bitshares/bitshares-core.git - 445 cd bitshares-core/ - 446 git submodule update --init --recursive - 447 sudo gedit config.ini - 448 cd / - 449 cd ~ - 450 sudo apt-get install openvpn - 451 sudo apt-get install openvpn network-manager-openvpn network-manager-openvpn-gnome - 452 cd /tmp/graphene-tmp/ - 453 ls - 454 sudo 962d-abf0-9900-1c34/ - 455 cd 962d-abf0-9900-1c34/ - 456 ls - 457 cd blockchain/ - 458 ls - 459 cd .. - 460 cd 7da6-1a00-0b11-9d3e/ - 461 ls - 462 sudo ./clion.sh - 463 cd.. - 464 cd .. - 465 sudo cd VPNBook.com-OpenVPN-FR1/ - 466 vi history_api_tests.cpp - 467 vim history_api_tests.cpp - 468 sudo apt-get install vim - 469 vim history_api_tests.cpp - 470 sudo apt-get install doxygen - 471 cd /tmp/ - 472 ls - 473 cd graphene-tmp/ - 474 ls - 475 clear - 476 ls - 477 cd 15e3-5f1e-ad93-53b8/ - 478 ls - 479 gedit config.ini - 480 cd .. - 481 ls - 482 cd 58e7-d6d0-7c69-f537/ - 483 cd .. - 484 cd rm -rf graphene-tmp/ - 485 sudo rm -rf graphene-tmp/ - 486 cd graphene-tmp/ - 487 ls - 488 cd 55ba-b8fc-221d-c793/ - 489 ls - 490 cd .. - 491 cd 90ca-f4e8-134d-ff97/ - 492 ls - 493 sudo gedit config.ini - 494 cd .. - 495 ls - 496 cd .. - 497 rm -rf graphene-tmp/ - 498 sudo rm -rf graphene-tmp/ - 499 git add . - 500 git push origin 782_test_p1 - 501 git pull - 502 git push origin 782_test_p1 - 503 git add . - 504 git commit -m "updated based on review comment received" - 505 git push origin 782_test_p1 - 506 git pull origin 782_test_p1 - 507 git add . - 508 git commit -m "updated based on review comment received1" - 509 git push origin 782_test_p1 - 510 history> cmd.txt From 30666297d8717dd0da07883a54e9d1531cebb1d9 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 14 Jan 2019 19:23:15 -0800 Subject: [PATCH 09/20] 782 chnages based on review comments --- libraries/app/api.cpp | 20 +- libraries/app/include/graphene/app/api.hpp | 6 +- libraries/chain/market_evaluator.cpp | 4 +- tests/tests/app_util_tests.cpp | 2 +- tests/tests/group_order_api_tests.cpp | 44 ++- tests/tests/history_api_tests.cpp | 305 +++++++++++---------- 6 files changed, 190 insertions(+), 191 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 142b5153c2..309636b40e 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -530,14 +530,17 @@ namespace graphene { namespace app { } // asset_api + asset_api::asset_api(application& app) :_app(app),_db(std::ref(*app.chain_database())) { + FC_ASSERT(_app.chain_database() ); + } + asset_api::~asset_api() { } + vector asset_api::get_asset_holders( asset_id_type asset_id, uint32_t start, uint32_t limit ) const { - FC_ASSERT( _app.chain_database() ); - const auto& db = *_app.chain_database(); uint64_t api_limit_get_asset_holders=_app.get_options().api_limit_get_asset_holders; FC_ASSERT(limit <= api_limit_get_asset_holders); - const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); vector result; @@ -554,7 +557,7 @@ namespace graphene { namespace app { if( index++ < start ) continue; - const auto account = db.find(bal.owner); + const auto account = _db.find(bal.owner); account_asset_balance aab; aab.name = account->name; @@ -579,19 +582,16 @@ namespace graphene { namespace app { } // function to get vector of system assets with holders count. vector asset_api::get_all_asset_holders() const { - FC_ASSERT( _app.chain_database() ); - const auto& db = *_app.chain_database(); vector result; - vector total_assets; - for( const asset_object& asset_obj : db.get_index_type().indices() ) + for( const asset_object& asset_obj : _db.get_index_type().indices() ) { - const auto& dasset_obj = asset_obj.dynamic_asset_data_id(db); + const auto& dasset_obj = asset_obj.dynamic_asset_data_id(_db); asset_id_type asset_id; asset_id = dasset_obj.id; - const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); int count = boost::distance(range) - 1; diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 258391a942..2ba6e224ff 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -438,8 +438,8 @@ namespace graphene { namespace app { class asset_api { public: - asset_api(application& app) - :_app(app), database_api( std::ref(*app.chain_database()), &(app.get_options())) {} + asset_api(application& app); + ~asset_api(); /** * @brief Get asset holders for a specific asset @@ -465,7 +465,7 @@ namespace graphene { namespace app { private: application& _app; - graphene::app::database_api database_api; + graphene::chain::database& _db; }; /** diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 58dd0ac53f..4baa297947 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -49,11 +49,11 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o _receive_asset = &op.min_to_receive.asset_id(d); if( _sell_asset->options.whitelist_markets.size() ) - FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) + FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) != _sell_asset->options.whitelist_markets.end(), "This market has not been whitelisted." ); if( _sell_asset->options.blacklist_markets.size() ) - FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) + FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end(), "This market has been blacklisted." ); diff --git a/tests/tests/app_util_tests.cpp b/tests/tests/app_util_tests.cpp index b85c9a3e8d..987e08c82e 100644 --- a/tests/tests/app_util_tests.cpp +++ b/tests/tests/app_util_tests.cpp @@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(price_to_string_verify) BOOST_CHECK_EQUAL( price_to_string( price{ asset(mx), asset(mx) }, 0, 0), "1" ); BOOST_CHECK_EQUAL( price_to_string( price{ asset(1), asset(mx) }, 0, 0), "0.0000000000000000001" ); BOOST_CHECK_EQUAL( price_to_string( price{ asset(mx), asset(1) }, 0, 0), "9223372036854775807" ); - } + } catch (fc::exception& fx) { BOOST_FAIL( "FC Exception: " + fx.to_detail_string() ); diff --git a/tests/tests/group_order_api_tests.cpp b/tests/tests/group_order_api_tests.cpp index b12d34fb0c..3381afc350 100644 --- a/tests/tests/group_order_api_tests.cpp +++ b/tests/tests/group_order_api_tests.cpp @@ -34,33 +34,31 @@ using namespace graphene::chain::test; using namespace graphene::app; BOOST_FIXTURE_TEST_SUITE(grouped_orders_api_tests, database_fixture) - BOOST_AUTO_TEST_CASE(api_limit_get_grouped_limit_orders) { - try { - graphene::app::orders_api orders_api(app); - optional< api_access_info > acc; - optional start; - - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); - - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; - generate_block(); - fc::usleep(fc::milliseconds(2000)); + try + { + graphene::app::orders_api orders_api(app); + optional< api_access_info > acc; + optional start; - int asset_create_op_id = operation::tag::value; - int account_create_op_id = operation::tag::value; + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); - GRAPHENE_CHECK_THROW(orders_api.get_grouped_limit_orders(asset_id_type(), asset_id_type(),10, start,260), fc::exception) - vector< limit_order_group > orders =orders_api.get_grouped_limit_orders(asset_id_type(), bit_jmj_id, 10,start,240); - BOOST_REQUIRE_EQUAL( orders.size(), 0); + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + generate_block(); + fc::usleep(fc::milliseconds(2000)); - } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; - } + GRAPHENE_CHECK_THROW(orders_api.get_grouped_limit_orders(asset_id_type(), asset_id_type(),10, start,260), fc::exception); + vector< limit_order_group > orders =orders_api.get_grouped_limit_orders(asset_id_type(), bit_jmj_id, 10,start,240); + BOOST_REQUIRE_EQUAL( orders.size(), 0); + } + catch (fc::exception &e) + { + edump((e.to_detail_string())); + throw; + } } diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 5e303caa1c..8f29bcffdb 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -549,7 +549,6 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { int asset_create_op_id = operation::tag::value; int account_create_op_id = operation::tag::value; - int transfer_op_id = operation::tag::value; //account_id_type() did 1 asset_create op vector histories = hist_api.get_account_history_operations( @@ -606,168 +605,170 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { } //new test case for increasing the limit based on the config file BOOST_AUTO_TEST_CASE(api_limit_get_account_history_operations) { - try { - graphene::app::history_api hist_api(app); - - //account_id_type() do 3 ops - create_bitasset("CNY", account_id_type()); - create_account("sam"); - create_account("alice"); - - generate_block(); - fc::usleep(fc::milliseconds(2000)); - - int asset_create_op_id = operation::tag::value; - int account_create_op_id = operation::tag::value; - int transfer_op_id = operation::tag::value; - - //account_id_type() did 1 asset_create op - vector histories = hist_api.get_account_history_operations( - "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); - BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); - - //account_id_type() did 2 account_create ops - histories = hist_api.get_account_history_operations( - "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // No asset_create op larger than id1 - histories = hist_api.get_account_history_operations( - "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 200); - BOOST_CHECK_EQUAL(histories.size(), 0); - - // Limit 1 returns 1 result - histories = hist_api.get_account_history_operations( - "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // alice has 1 op - histories = hist_api.get_account_history_operations( - "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // create a bunch of accounts - for(int i = 0; i < 126; ++i) - { - std::string acct_name = "mytempacct" + std::to_string(i); - create_account(acct_name); - } - generate_block(); - - // history is set to limit transactions to 125 (see database_fixture.hpp) - // so asking for more should only return 125 (and not throw exception, - // see https://github.com/bitshares/bitshares-core/issues/1490 - GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type() ,operation_history_id_type(), 301), fc::exception) - histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); - } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; - } + try { + graphene::app::history_api hist_api(app); + + //account_id_type() do 3 ops + create_bitasset("CNY", account_id_type()); + create_account("sam"); + create_account("alice"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + int asset_create_op_id = operation::tag::value; + int account_create_op_id = operation::tag::value; + + //account_id_type() did 1 asset_create op + vector histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); + + //account_id_type() did 2 account_create ops + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // No asset_create op larger than id1 + histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 200); + BOOST_CHECK_EQUAL(histories.size(), 0); + + // Limit 1 returns 1 result + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // alice has 1 op + histories = hist_api.get_account_history_operations( + "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // create a bunch of accounts + for(int i = 0; i < 126; ++i) + { + std::string acct_name = "mytempacct" + std::to_string(i); + create_account(acct_name); + } + generate_block(); + + // history is set to limit transactions to 125 (see database_fixture.hpp) + // so asking for more should only return 125 (and not throw exception, + // see https://github.com/bitshares/bitshares-core/issues/1490 + GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 301), fc::exception); + histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + } + catch (fc::exception &e) + { + edump((e.to_detail_string())); + throw; + } } BOOST_AUTO_TEST_CASE(api_limit_get_account_history) { - try { - graphene::app::history_api hist_api(app); - - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); - - generate_block(); - fc::usleep(fc::milliseconds(2000)); - - int asset_create_op_id = operation::tag::value; - int account_create_op_id = operation::tag::value; - //account_id_type() did 3 ops and includes id0 - vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); - - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); - BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); - - // 1 account_create op larger than id1 - histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 210, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK(histories[0].id.instance() != 0); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - - // Limit 2 returns 2 result - histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK(histories[1].id.instance() != 0); - BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); - // bob has 1 op - histories = hist_api.get_account_history("bob", operation_history_id_type(), 210, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // create a bunch of accounts - for(int i = 0; i < 126; ++i) - { - std::string acct_name = "mytempacct" + std::to_string(i); - create_account(acct_name); - } - generate_block(); - - GRAPHENE_CHECK_THROW(hist_api.get_account_history("1.2.0", operation_history_id_type(), 260, operation_history_id_type()), fc::exception) - histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); - - } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; - } + try + { + graphene::app::history_api hist_api(app); + + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + int asset_create_op_id = operation::tag::value; + int account_create_op_id = operation::tag::value; + //account_id_type() did 3 ops and includes id0 + vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); + + BOOST_CHECK_EQUAL(histories.size(), 3); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); + + // 1 account_create op larger than id1 + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 210, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK(histories[0].id.instance() != 0); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + + // Limit 2 returns 2 result + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK(histories[1].id.instance() != 0); + BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); + // bob has 1 op + histories = hist_api.get_account_history("bob", operation_history_id_type(), 210, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // create a bunch of accounts + for(int i = 0; i < 126; ++i) + { + std::string acct_name = "mytempacct" + std::to_string(i); + create_account(acct_name); + } + generate_block(); + + GRAPHENE_CHECK_THROW(hist_api.get_account_history("1.2.0", operation_history_id_type(), 260, operation_history_id_type()), fc::exception); + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + + } catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } } BOOST_AUTO_TEST_CASE(api_limit_get_relative_account_history) { - try { - graphene::app::history_api hist_api(app); - - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); + try + { + graphene::app::history_api hist_api(app); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); - generate_block(); - fc::usleep(fc::milliseconds(2000)); + generate_block(); + fc::usleep(fc::milliseconds(2000)); - GRAPHENE_CHECK_THROW(hist_api.get_relative_account_history("1.2.0", 126, 260, 0), fc::exception) - vector histories = hist_api.get_relative_account_history("1.2.0", 126, 210, 0); - BOOST_REQUIRE_EQUAL( histories.size(), 0 ); + GRAPHENE_CHECK_THROW(hist_api.get_relative_account_history("1.2.0", 126, 260, 0), fc::exception); + vector histories = hist_api.get_relative_account_history("1.2.0", 126, 210, 0); + BOOST_REQUIRE_EQUAL( histories.size(), 0 ); - } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; - } + } catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } } BOOST_AUTO_TEST_CASE(api_limit_get_account_history_by_operations) { - try { - graphene::app::history_api hist_api(app); - vector operation_types; - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); - - generate_block(); - fc::usleep(fc::milliseconds(2000)); - - GRAPHENE_CHECK_THROW(hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 260), fc::exception) - history_operation_detail histories = hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 210); - BOOST_REQUIRE_EQUAL( histories.total_count, 0 ); - - } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; - } + try { + graphene::app::history_api hist_api(app); + vector operation_types; + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + GRAPHENE_CHECK_THROW(hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 260), fc::exception); + history_operation_detail histories = hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 210); + BOOST_REQUIRE_EQUAL( histories.total_count, 0 ); + + } + catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } } From 9d6b06f3e9c4f2f1e6d0739ce364fc9345bc75d0 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 14 Jan 2019 21:08:32 -0800 Subject: [PATCH 10/20] 782 changes based on travis build and review comments --- tests/common/database_fixture.cpp | 1 + tests/tests/history_api_tests.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index d82fa773c3..3061564bc7 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -146,6 +146,7 @@ database_fixture::database_fixture() if(current_test_name =="api_limit_get_account_history_by_operations") { options.insert(std::make_pair("api-limit-get-account-history-by-operations", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("api-limit-get-relative-account-history", boost::program_options::variable_value((uint64_t)250, false))); options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } if(current_test_name =="api_limit_get_asset_holders") diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 8f29bcffdb..51c49c44a8 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -762,7 +762,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_account_history_by_operations) { GRAPHENE_CHECK_THROW(hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 260), fc::exception); history_operation_detail histories = hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 210); - BOOST_REQUIRE_EQUAL( histories.total_count, 0 ); + BOOST_REQUIRE_EQUAL( histories.total_count, 3 ); } catch (fc::exception &e) { From 884a6b458ff5d5d0a8f4bf3ec832d461d40e9c47 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 14 Jan 2019 21:12:05 -0800 Subject: [PATCH 11/20] 782 changes based on travis build and review comments --- libraries/app/api.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 309636b40e..a043d5bad0 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -571,9 +571,7 @@ namespace graphene { namespace app { } // get number of asset holders. int asset_api::get_asset_holders_count( asset_id_type asset_id ) const { - FC_ASSERT( _app.chain_database() ); - const auto& db = *_app.chain_database(); - const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); int count = boost::distance(range) - 1; From f6f6cde127e89c3e6fccec95b3ac255d1da3835d Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 14 Jan 2019 21:15:01 -0800 Subject: [PATCH 12/20] Update group_order_api_tests.cpp --- tests/tests/group_order_api_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests/group_order_api_tests.cpp b/tests/tests/group_order_api_tests.cpp index 3381afc350..194f6686c9 100644 --- a/tests/tests/group_order_api_tests.cpp +++ b/tests/tests/group_order_api_tests.cpp @@ -37,7 +37,7 @@ BOOST_FIXTURE_TEST_SUITE(grouped_orders_api_tests, database_fixture) BOOST_AUTO_TEST_CASE(api_limit_get_grouped_limit_orders) { try { - graphene::app::orders_api orders_api(app); + graphene::app::orders_api orders_api(app); optional< api_access_info > acc; optional start; @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_grouped_limit_orders) { } catch (fc::exception &e) { - edump((e.to_detail_string())); + edump((e.to_detail_string())); throw; } } From f85b46d42b1205ef95e8ef2a1976cad02c23b553 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 14 Jan 2019 21:17:27 -0800 Subject: [PATCH 13/20] Update api.hpp --- libraries/app/include/graphene/app/api.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 2ba6e224ff..cabb568e78 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -438,8 +438,8 @@ namespace graphene { namespace app { class asset_api { public: - asset_api(application& app); - ~asset_api(); + asset_api(application& app); + ~asset_api(); /** * @brief Get asset holders for a specific asset From 8d59ea34c22829b64ef8dd64b39762f0f3845c55 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Tue, 15 Jan 2019 02:11:15 -0800 Subject: [PATCH 14/20] 782 changes based on get_key_references --- libraries/app/application.cpp | 5 +++ libraries/app/database_api.cpp | 6 ++-- libraries/app/include/graphene/app/api.hpp | 4 +-- .../app/include/graphene/app/application.hpp | 1 + tests/common/database_fixture.cpp | 8 ++++- tests/tests/database_api_tests.cpp | 34 +++++++++++++++++++ 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index e33731d492..06a950fe05 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -338,6 +338,9 @@ void application_impl::set_dgb_api_limit_api() { if(_options->count("api-limit-get-asset-holders")){ _app_options.api_limit_get_asset_holders = _options->at("api-limit-get-asset-holders").as(); } + if(_options->count("api-limit-get-key-references")){ + _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); + } } @@ -1019,6 +1022,8 @@ void application::set_program_options(boost::program_options::options_descriptio "For history_api::get_account_history_by_operations to set its default limit value as 100") ("api-limit-get-asset-holders",boost::program_options::value()->default_value(100), "For asset_api::get_asset_holders to set its default limit value as 100") + ("api-limit-get-key-references",boost::program_options::value()->default_value(100), + "For database_api_impl::get_key_references to set its default limit value as 100") ; command_line_options.add(configuration_file_options); command_line_options.add_options() diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 28182fd08d..62af17b3f0 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -539,7 +539,6 @@ dynamic_global_property_object database_api_impl::get_dynamic_global_properties( vector> database_api::get_key_references( vector key )const { - FC_ASSERT(key.size() <= 100, "Number of keys must be 100 or less"); return my->get_key_references( key ); } @@ -548,7 +547,10 @@ vector> database_api::get_key_references( vector> database_api_impl::get_key_references( vector keys )const { - const auto& idx = _db.get_index_type(); + FC_ASSERT( _app_options && _app_options->api_limit_get_key_references, "App needs to be passed"); + uint64_t api_limit_get_key_references=_app_options->api_limit_get_key_references; + FC_ASSERT(keys.size() <= api_limit_get_key_references); + const auto& idx = _db.get_index_type(); const auto& aidx = dynamic_cast(idx); const auto& refs = aidx.get_secondary_index(); diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index cabb568e78..cdc86335b7 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -438,8 +438,8 @@ namespace graphene { namespace app { class asset_api { public: - asset_api(application& app); - ~asset_api(); + asset_api(application& app); + ~asset_api(); /** * @brief Get asset holders for a specific asset diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 13f507b1b0..9387594e88 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -46,6 +46,7 @@ namespace graphene { namespace app { uint64_t api_limit_get_relative_account_history=100; uint64_t api_limit_get_account_history_by_operations=100; uint64_t api_limit_get_asset_holders=100; + uint64_t api_limit_get_key_references=100; }; class application diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 3061564bc7..af0657e597 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -154,6 +154,11 @@ database_fixture::database_fixture() options.insert(std::make_pair("api-limit-get-asset-holders", boost::program_options::variable_value((uint64_t)250, false))); options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } + if(current_test_name =="api_limit_get_key_references") + { + options.insert(std::make_pair("api-limit-get-key-references", boost::program_options::variable_value((uint64_t)200, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } // add account tracking for ahplugin for special test case with track-account enabled if( !options.count("track-account") && current_test_name == "track_account") { @@ -198,7 +203,8 @@ database_fixture::database_fixture() ahplugin->plugin_startup(); if (current_test_name == "api_limit_get_account_history_operations" || current_test_name == "api_limit_get_account_history" || current_test_name == "api_limit_get_grouped_limit_orders" || current_test_name == "api_limit_get_relative_account_history" - || current_test_name == "api_limit_get_account_history_by_operations" || current_test_name =="api_limit_get_asset_holders") + || current_test_name == "api_limit_get_account_history_by_operations" || current_test_name =="api_limit_get_asset_holders" + || current_test_name =="api_limit_get_key_references") { app.initialize(graphene::utilities::temp_directory_path(), options); app.set_dgb_api_limit_api(); diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 1eeb177b42..e302b3b39e 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -940,5 +940,39 @@ BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) throw; } } +BOOST_AUTO_TEST_CASE( api_limit_get_key_references ) +{ + try + { + const int num_keys = 210; + const int num_keys1 = 2; + vector< private_key_type > numbered_private_keys; + vector< public_key_type > numbered_key_id; + numbered_private_keys.reserve( num_keys ); + graphene::app::database_api db_api( db, &( app.get_options() )); + for( int i=0; i > final_result=db_api.get_key_references(numbered_key_id); + BOOST_REQUIRE_EQUAL( final_result.size(), 2 ); + numbered_private_keys.reserve( num_keys ); + for( int i=num_keys1; i Date: Tue, 15 Jan 2019 02:18:31 -0800 Subject: [PATCH 15/20] Update application.hpp --- libraries/app/include/graphene/app/application.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 9387594e88..dbab18d664 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -46,7 +46,7 @@ namespace graphene { namespace app { uint64_t api_limit_get_relative_account_history=100; uint64_t api_limit_get_account_history_by_operations=100; uint64_t api_limit_get_asset_holders=100; - uint64_t api_limit_get_key_references=100; + uint64_t api_limit_get_key_references=100; }; class application From 097a8e67c2a27cf6cf76c7142298e60753ef52c3 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Tue, 15 Jan 2019 13:10:20 -0800 Subject: [PATCH 16/20] changes for 782 to correct spacing issue --- tests/tests/database_api_tests.cpp | 57 +++--- tests/tests/group_order_api_tests.cpp | 36 ++-- tests/tests/history_api_tests.cpp | 241 +++++++++++++------------- 3 files changed, 163 insertions(+), 171 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index e302b3b39e..73e8760c2f 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -940,39 +940,36 @@ BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) throw; } } -BOOST_AUTO_TEST_CASE( api_limit_get_key_references ) -{ - try +BOOST_AUTO_TEST_CASE( api_limit_get_key_references ){ + try{ + const int num_keys = 210; + const int num_keys1 = 2; + vector< private_key_type > numbered_private_keys; + vector< public_key_type > numbered_key_id; + numbered_private_keys.reserve( num_keys ); + graphene::app::database_api db_api( db, &( app.get_options() )); + for( int i=0; i > final_result=db_api.get_key_references(numbered_key_id); + BOOST_REQUIRE_EQUAL( final_result.size(), 2 ); + numbered_private_keys.reserve( num_keys ); + for( int i=num_keys1; i numbered_private_keys; - vector< public_key_type > numbered_key_id; - numbered_private_keys.reserve( num_keys ); - graphene::app::database_api db_api( db, &( app.get_options() )); - for( int i=0; i > final_result=db_api.get_key_references(numbered_key_id); - BOOST_REQUIRE_EQUAL( final_result.size(), 2 ); - numbered_private_keys.reserve( num_keys ); - for( int i=num_keys1; i acc; - optional start; + try + { + graphene::app::orders_api orders_api(app); + optional< api_access_info > acc; + optional start; - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; - generate_block(); - fc::usleep(fc::milliseconds(2000)); + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + generate_block(); + fc::usleep(fc::milliseconds(2000)); - GRAPHENE_CHECK_THROW(orders_api.get_grouped_limit_orders(asset_id_type(), asset_id_type(),10, start,260), fc::exception); - vector< limit_order_group > orders =orders_api.get_grouped_limit_orders(asset_id_type(), bit_jmj_id, 10,start,240); - BOOST_REQUIRE_EQUAL( orders.size(), 0); + GRAPHENE_CHECK_THROW(orders_api.get_grouped_limit_orders(asset_id_type(), asset_id_type(),10, start,260), fc::exception); + vector< limit_order_group > orders =orders_api.get_grouped_limit_orders(asset_id_type(), bit_jmj_id, 10,start,240); + BOOST_REQUIRE_EQUAL( orders.size(), 0); } catch (fc::exception &e) - { - edump((e.to_detail_string())); - throw; + { + edump((e.to_detail_string())); + throw; } } diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 51c49c44a8..120fe5494f 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -606,146 +606,141 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { //new test case for increasing the limit based on the config file BOOST_AUTO_TEST_CASE(api_limit_get_account_history_operations) { try { - graphene::app::history_api hist_api(app); - - //account_id_type() do 3 ops - create_bitasset("CNY", account_id_type()); - create_account("sam"); - create_account("alice"); - - generate_block(); - fc::usleep(fc::milliseconds(2000)); - - int asset_create_op_id = operation::tag::value; - int account_create_op_id = operation::tag::value; - - //account_id_type() did 1 asset_create op - vector histories = hist_api.get_account_history_operations( - "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); - BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); - - //account_id_type() did 2 account_create ops - histories = hist_api.get_account_history_operations( - "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // No asset_create op larger than id1 - histories = hist_api.get_account_history_operations( - "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 200); - BOOST_CHECK_EQUAL(histories.size(), 0); - - // Limit 1 returns 1 result - histories = hist_api.get_account_history_operations( - "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // alice has 1 op - histories = hist_api.get_account_history_operations( - "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // create a bunch of accounts - for(int i = 0; i < 126; ++i) - { - std::string acct_name = "mytempacct" + std::to_string(i); - create_account(acct_name); - } - generate_block(); - - // history is set to limit transactions to 125 (see database_fixture.hpp) - // so asking for more should only return 125 (and not throw exception, - // see https://github.com/bitshares/bitshares-core/issues/1490 - GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 301), fc::exception); - histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + graphene::app::history_api hist_api(app); + //account_id_type() do 3 ops + create_bitasset("CNY", account_id_type()); + create_account("sam"); + create_account("alice"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + int asset_create_op_id = operation::tag::value; + int account_create_op_id = operation::tag::value; + + //account_id_type() did 1 asset_create op + vector histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); + + //account_id_type() did 2 account_create ops + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // No asset_create op larger than id1 + histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 200); + BOOST_CHECK_EQUAL(histories.size(), 0); + + // Limit 1 returns 1 result + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // alice has 1 op + histories = hist_api.get_account_history_operations( + "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 200); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // create a bunch of accounts + for(int i = 0; i < 126; ++i) + { + std::string acct_name = "mytempacct" + std::to_string(i); + create_account(acct_name); + } + generate_block(); + + // history is set to limit transactions to 125 (see database_fixture.hpp) + // so asking for more should only return 125 (and not throw exception, + // see https://github.com/bitshares/bitshares-core/issues/1490 + GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 301), fc::exception); + histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; + edump((e.to_detail_string())); + throw; } } BOOST_AUTO_TEST_CASE(api_limit_get_account_history) { - try + try{ + graphene::app::history_api hist_api(app); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + + generate_block(); + fc::usleep(fc::milliseconds(2000)); + + int asset_create_op_id = operation::tag::value; + int account_create_op_id = operation::tag::value; + //account_id_type() did 3 ops and includes id0 + vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); + + BOOST_CHECK_EQUAL(histories.size(), 3); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); + + // 1 account_create op larger than id1 + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 210, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK(histories[0].id.instance() != 0); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + + // Limit 2 returns 2 result + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK(histories[1].id.instance() != 0); + BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); + // bob has 1 op + histories = hist_api.get_account_history("bob", operation_history_id_type(), 210, operation_history_id_type()); + BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + // create a bunch of accounts + for(int i = 0; i < 126; ++i) { - graphene::app::history_api hist_api(app); - - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); - - generate_block(); - fc::usleep(fc::milliseconds(2000)); - - int asset_create_op_id = operation::tag::value; - int account_create_op_id = operation::tag::value; - //account_id_type() did 3 ops and includes id0 - vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); - - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); - BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); - - // 1 account_create op larger than id1 - histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 210, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK(histories[0].id.instance() != 0); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - - // Limit 2 returns 2 result - histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK(histories[1].id.instance() != 0); - BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); - // bob has 1 op - histories = hist_api.get_account_history("bob", operation_history_id_type(), 210, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); - - // create a bunch of accounts - for(int i = 0; i < 126; ++i) - { - std::string acct_name = "mytempacct" + std::to_string(i); - create_account(acct_name); - } - generate_block(); - - GRAPHENE_CHECK_THROW(hist_api.get_account_history("1.2.0", operation_history_id_type(), 260, operation_history_id_type()), fc::exception); - histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + std::string acct_name = "mytempacct" + std::to_string(i); + create_account(acct_name); + } + generate_block(); + GRAPHENE_CHECK_THROW(hist_api.get_account_history("1.2.0", operation_history_id_type(), 260, operation_history_id_type()), fc::exception); + histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); + BOOST_REQUIRE_EQUAL( histories.size(), 125 ); } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; + edump((e.to_detail_string())); + throw; } } BOOST_AUTO_TEST_CASE(api_limit_get_relative_account_history) { - try - { - graphene::app::history_api hist_api(app); - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); + try{ + graphene::app::history_api hist_api(app); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); - generate_block(); - fc::usleep(fc::milliseconds(2000)); + generate_block(); + fc::usleep(fc::milliseconds(2000)); - GRAPHENE_CHECK_THROW(hist_api.get_relative_account_history("1.2.0", 126, 260, 0), fc::exception); - vector histories = hist_api.get_relative_account_history("1.2.0", 126, 210, 0); - BOOST_REQUIRE_EQUAL( histories.size(), 0 ); + GRAPHENE_CHECK_THROW(hist_api.get_relative_account_history("1.2.0", 126, 260, 0), fc::exception); + vector histories = hist_api.get_relative_account_history("1.2.0", 126, 210, 0); + BOOST_REQUIRE_EQUAL( histories.size(), 0 ); } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; + edump((e.to_detail_string())); + throw; } } From ba3a895252c6f4c02977ebaee213957a5ba58678 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Tue, 15 Jan 2019 13:22:57 -0800 Subject: [PATCH 17/20] Update database_api_tests.cpp --- tests/tests/database_api_tests.cpp | 54 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 73e8760c2f..72cf23b1c0 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -943,33 +943,33 @@ BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) BOOST_AUTO_TEST_CASE( api_limit_get_key_references ){ try{ const int num_keys = 210; - const int num_keys1 = 2; - vector< private_key_type > numbered_private_keys; - vector< public_key_type > numbered_key_id; - numbered_private_keys.reserve( num_keys ); - graphene::app::database_api db_api( db, &( app.get_options() )); - for( int i=0; i > final_result=db_api.get_key_references(numbered_key_id); - BOOST_REQUIRE_EQUAL( final_result.size(), 2 ); - numbered_private_keys.reserve( num_keys ); - for( int i=num_keys1; i numbered_private_keys; + vector< public_key_type > numbered_key_id; + numbered_private_keys.reserve( num_keys ); + graphene::app::database_api db_api( db, &( app.get_options() )); + for( int i=0; i > final_result=db_api.get_key_references(numbered_key_id); + BOOST_REQUIRE_EQUAL( final_result.size(), 2 ); + numbered_private_keys.reserve( num_keys ); + for( int i=num_keys1; i Date: Tue, 15 Jan 2019 13:25:58 -0800 Subject: [PATCH 18/20] Update as per the review comments 1513 --- libraries/app/api.cpp | 12 ++-- libraries/app/application.cpp | 12 ++-- libraries/app/application_impl.hxx | 2 +- libraries/app/database_api.cpp | 7 +- libraries/app/include/graphene/app/api.hpp | 9 +-- .../app/include/graphene/app/application.hpp | 16 ++--- libraries/chain/market_evaluator.cpp | 4 +- tests/common/database_fixture.cpp | 39 ++++++----- tests/tests/app_util_tests.cpp | 2 +- tests/tests/asset_api_tests.cpp | 6 +- tests/tests/database_api_tests.cpp | 3 +- ...tests.cpp => grouped_orders_api_tests.cpp} | 30 ++++---- tests/tests/history_api_tests.cpp | 68 +++++++++---------- 13 files changed, 101 insertions(+), 109 deletions(-) rename tests/tests/{group_order_api_tests.cpp => grouped_orders_api_tests.cpp} (69%) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index a043d5bad0..482cbffc6d 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -530,15 +530,15 @@ namespace graphene { namespace app { } // asset_api - asset_api::asset_api(application& app) :_app(app),_db(std::ref(*app.chain_database())) { - FC_ASSERT(_app.chain_database() ); - } + asset_api::asset_api(graphene::app::application& app) : + _app(app), + _db( *app.chain_database()), + database_api( std::ref(*app.chain_database()), &(app.get_options()) + ) { } asset_api::~asset_api() { } vector asset_api::get_asset_holders( asset_id_type asset_id, uint32_t start, uint32_t limit ) const { - uint64_t api_limit_get_asset_holders=_app.get_options().api_limit_get_asset_holders; - FC_ASSERT(limit <= api_limit_get_asset_holders); const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); @@ -620,7 +620,7 @@ namespace graphene { namespace app { { uint64_t api_limit_get_grouped_limit_orders=_app.get_options().api_limit_get_grouped_limit_orders; FC_ASSERT( limit <= api_limit_get_grouped_limit_orders ); - auto plugin = _app.get_plugin( "grouped_orders" ); + auto plugin = _app.get_plugin( "grouped_orders" ); FC_ASSERT( plugin ); const auto& limit_groups = plugin->limit_order_groups(); vector< limit_order_group > result; diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 06a950fe05..6ded8fefb6 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -319,7 +319,8 @@ void application_impl::set_dbg_init_key( graphene::chain::genesis_state_type& ge } -void application_impl::set_dgb_api_limit_api() { + +void application_impl::set_api_limit() { if (_options->count("api-limit-get-account-history-operations")) { _app_options.api_limit_get_account_history_operations = _options->at("api-limit-get-account-history-operations").as(); } @@ -341,7 +342,6 @@ void application_impl::set_dgb_api_limit_api() { if(_options->count("api-limit-get-key-references")){ _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); } - } void application_impl::startup() @@ -465,7 +465,7 @@ void application_impl::startup() if ( _options->count("enable-subscribe-to-all") ) _app_options.enable_subscribe_to_all = _options->at( "enable-subscribe-to-all" ).as(); - set_dgb_api_limit_api(); + set_api_limit(); if( _active_plugins.find( "market_history" ) != _active_plugins.end() ) _app_options.has_market_history_plugin = true; @@ -1118,10 +1118,11 @@ void application::startup() throw; } } -void application::set_dgb_api_limit_api() + +void application::set_api_limit() { try { - my->set_dgb_api_limit_api(); + my->set_api_limit(); } catch ( const fc::exception& e ) { elog( "${e}", ("e",e.to_detail_string()) ); throw; @@ -1130,7 +1131,6 @@ void application::set_dgb_api_limit_api() throw; } } - std::shared_ptr application::get_plugin(const string& name) const { return my->_active_plugins[name]; diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 7539b71065..edb75f9c16 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -41,7 +41,7 @@ class application_impl : public net::node_delegate } void set_dbg_init_key( graphene::chain::genesis_state_type& genesis, const std::string& init_key ); - void set_dgb_api_limit_api(); + void set_api_limit(); void startup(); diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 62af17b3f0..bbc0f4f4a4 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -547,10 +547,9 @@ vector> database_api::get_key_references( vector> database_api_impl::get_key_references( vector keys )const { - FC_ASSERT( _app_options && _app_options->api_limit_get_key_references, "App needs to be passed"); - uint64_t api_limit_get_key_references=_app_options->api_limit_get_key_references; - FC_ASSERT(keys.size() <= api_limit_get_key_references); - const auto& idx = _db.get_index_type(); + uint64_t api_limit_get_key_references=_app_options->api_limit_get_key_references; + FC_ASSERT(keys.size() <= api_limit_get_key_references); + const auto& idx = _db.get_index_type(); const auto& aidx = dynamic_cast(idx); const auto& refs = aidx.get_secondary_index(); diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index cdc86335b7..ec00b44d01 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -438,8 +438,8 @@ namespace graphene { namespace app { class asset_api { public: - asset_api(application& app); - ~asset_api(); + asset_api(application& app); + ~asset_api(); /** * @brief Get asset holders for a specific asset @@ -464,8 +464,9 @@ namespace graphene { namespace app { vector get_all_asset_holders() const; private: - application& _app; - graphene::chain::database& _db; + graphene::app::application& _app; + graphene::chain::database& _db; + graphene::app::database_api database_api; }; /** diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index dbab18d664..ee3ce7478f 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -40,13 +40,13 @@ namespace graphene { namespace app { public: bool enable_subscribe_to_all = false; bool has_market_history_plugin = false; - uint64_t api_limit_get_account_history_operations=100; - uint64_t api_limit_get_account_history=100; - uint64_t api_limit_get_grouped_limit_orders=101; - uint64_t api_limit_get_relative_account_history=100; - uint64_t api_limit_get_account_history_by_operations=100; - uint64_t api_limit_get_asset_holders=100; - uint64_t api_limit_get_key_references=100; + uint64_t api_limit_get_account_history_operations = 100; + uint64_t api_limit_get_account_history = 100; + uint64_t api_limit_get_grouped_limit_orders = 101; + uint64_t api_limit_get_relative_account_history = 100; + uint64_t api_limit_get_account_history_by_operations = 100; + uint64_t api_limit_get_asset_holders = 100; + uint64_t api_limit_get_key_references = 100; }; class application @@ -94,7 +94,7 @@ namespace graphene { namespace app { net::node_ptr p2p_node(); std::shared_ptr chain_database()const; - void set_dgb_api_limit_api(); + void set_api_limit(); void set_block_production(bool producing_blocks); fc::optional< api_access_info > get_api_access_info( const string& username )const; void set_api_access_info(const string& username, api_access_info&& permissions); diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 4baa297947..58dd0ac53f 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -49,11 +49,11 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o _receive_asset = &op.min_to_receive.asset_id(d); if( _sell_asset->options.whitelist_markets.size() ) - FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) + FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) != _sell_asset->options.whitelist_markets.end(), "This market has not been whitelisted." ); if( _sell_asset->options.blacklist_markets.size() ) - FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) + FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end(), "This market has been blacklisted." ); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index af0657e597..feaaf2b95d 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -122,44 +122,43 @@ database_fixture::database_fixture() } if (current_test_name == "api_limit_get_account_history_operations") { - options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); - options.insert(std::make_pair("api-limit-get-account-history-operations", boost::program_options::variable_value((uint64_t)300, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); + options.insert(std::make_pair("api-limit-get-account-history-operations", boost::program_options::variable_value((uint64_t)300, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } if(current_test_name =="api_limit_get_account_history") { - options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); - options.insert(std::make_pair("api-limit-get-account-history", boost::program_options::variable_value((uint64_t)250, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); + options.insert(std::make_pair("api-limit-get-account-history", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } if(current_test_name =="api_limit_get_grouped_limit_orders") { - options.insert(std::make_pair("api-limit-get-grouped-limit-orders", boost::program_options::variable_value((uint64_t)250, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("grouped_orders"), false))); + options.insert(std::make_pair("api-limit-get-grouped-limit-orders", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("grouped_orders"), false))); } if(current_test_name =="api_limit_get_relative_account_history") { - options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); - options.insert(std::make_pair("api-limit-get-relative-account-history", boost::program_options::variable_value((uint64_t)250, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)125, false))); + options.insert(std::make_pair("api-limit-get-relative-account-history", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } if(current_test_name =="api_limit_get_account_history_by_operations") { - options.insert(std::make_pair("api-limit-get-account-history-by-operations", boost::program_options::variable_value((uint64_t)250, false))); - options.insert(std::make_pair("api-limit-get-relative-account-history", boost::program_options::variable_value((uint64_t)250, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("api-limit-get-account-history-by-operations", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("api-limit-get-relative-account-history", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } if(current_test_name =="api_limit_get_asset_holders") { - options.insert(std::make_pair("api-limit-get-asset-holders", boost::program_options::variable_value((uint64_t)250, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("api-limit-get-asset-holders", boost::program_options::variable_value((uint64_t)250, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } if(current_test_name =="api_limit_get_key_references") { - options.insert(std::make_pair("api-limit-get-key-references", boost::program_options::variable_value((uint64_t)200, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("api-limit-get-key-references", boost::program_options::variable_value((uint64_t)200, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } - // add account tracking for ahplugin for special test case with track-account enabled if( !options.count("track-account") && current_test_name == "track_account") { std::vector track_account; @@ -207,7 +206,7 @@ database_fixture::database_fixture() || current_test_name =="api_limit_get_key_references") { app.initialize(graphene::utilities::temp_directory_path(), options); - app.set_dgb_api_limit_api(); + app.set_api_limit(); } } diff --git a/tests/tests/app_util_tests.cpp b/tests/tests/app_util_tests.cpp index 987e08c82e..b85c9a3e8d 100644 --- a/tests/tests/app_util_tests.cpp +++ b/tests/tests/app_util_tests.cpp @@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(price_to_string_verify) BOOST_CHECK_EQUAL( price_to_string( price{ asset(mx), asset(mx) }, 0, 0), "1" ); BOOST_CHECK_EQUAL( price_to_string( price{ asset(1), asset(mx) }, 0, 0), "0.0000000000000000001" ); BOOST_CHECK_EQUAL( price_to_string( price{ asset(mx), asset(1) }, 0, 0), "9223372036854775807" ); - } + } catch (fc::exception& fx) { BOOST_FAIL( "FC Exception: " + fx.to_detail_string() ); diff --git a/tests/tests/asset_api_tests.cpp b/tests/tests/asset_api_tests.cpp index a4e12fd63d..308b3acb84 100644 --- a/tests/tests/asset_api_tests.cpp +++ b/tests/tests/asset_api_tests.cpp @@ -76,9 +76,9 @@ BOOST_AUTO_TEST_CASE( api_limit_get_asset_holders ) transfer(account_id_type()(db), bob, asset(300)); // make call - GRAPHENE_CHECK_THROW(asset_api.get_asset_holders(asset_id_type(), 0, 260), fc::exception) - vector holders = asset_api.get_asset_holders(asset_id_type(), 0, 210);; - BOOST_REQUIRE_EQUAL( holders.size(), 4 ); + GRAPHENE_CHECK_THROW(asset_api.get_asset_holders(asset_id_type(), 0, 260), fc::exception); + vector holders = asset_api.get_asset_holders(asset_id_type(), 0, 210); + BOOST_REQUIRE_EQUAL( holders.size(), 4u ); } BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 72cf23b1c0..1a547b6b67 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -956,7 +956,7 @@ BOOST_AUTO_TEST_CASE( api_limit_get_key_references ){ numbered_key_id.push_back( pubkey ); } vector< vector > final_result=db_api.get_key_references(numbered_key_id); - BOOST_REQUIRE_EQUAL( final_result.size(), 2 ); + BOOST_REQUIRE_EQUAL( final_result.size(), 2u ); numbered_private_keys.reserve( num_keys ); for( int i=num_keys1; i acc; optional start; @@ -44,22 +45,17 @@ BOOST_AUTO_TEST_CASE(api_limit_get_grouped_limit_orders) { //account_id_type() do 3 ops create_bitasset("USD", account_id_type()); create_account("dan"); - create_account("bob"); - - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; - generate_block(); - fc::usleep(fc::milliseconds(2000)); - - GRAPHENE_CHECK_THROW(orders_api.get_grouped_limit_orders(asset_id_type(), asset_id_type(),10, start,260), fc::exception); - vector< limit_order_group > orders =orders_api.get_grouped_limit_orders(asset_id_type(), bit_jmj_id, 10,start,240); - BOOST_REQUIRE_EQUAL( orders.size(), 0); - } - catch (fc::exception &e) + create_account("bob"); + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + generate_block(); + fc::usleep(fc::milliseconds(100)); + GRAPHENE_CHECK_THROW(orders_api.get_grouped_limit_orders(std::string( static_cast(asset_id_type())), std::string( static_cast(asset_id_type())),10, start,260), fc::exception); + vector< limit_order_group > orders =orders_api.get_grouped_limit_orders(std::string( static_cast(asset_id_type())), std::string( static_cast(bit_jmj_id)), 10,start,240); + BOOST_REQUIRE_EQUAL( orders.size(), 0u); + }catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; - } + edump((e.to_detail_string())); + throw; + } } - - BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 120fe5494f..13c3c80dcf 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -589,7 +589,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { generate_block(); // history is set to limit transactions to 75 (see database_fixture.hpp) - // so asking for more should only return 75 (and not throw exception, + // so asking for more should only return 75 (and not throw exception, // see https://github.com/bitshares/bitshares-core/issues/1490 histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); @@ -613,7 +613,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_account_history_operations) { create_account("alice"); generate_block(); - fc::usleep(fc::milliseconds(2000)); + fc::usleep(fc::milliseconds(100)); int asset_create_op_id = operation::tag::value; int account_create_op_id = operation::tag::value; @@ -621,31 +621,31 @@ BOOST_AUTO_TEST_CASE(api_limit_get_account_history_operations) { //account_id_type() did 1 asset_create op vector histories = hist_api.get_account_history_operations( "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); //account_id_type() did 2 account_create ops histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // No asset_create op larger than id1 histories = hist_api.get_account_history_operations( "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 200); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // Limit 1 returns 1 result histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // alice has 1 op histories = hist_api.get_account_history_operations( "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 200); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // create a bunch of accounts @@ -661,7 +661,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_account_history_operations) { // see https://github.com/bitshares/bitshares-core/issues/1490 GRAPHENE_CHECK_THROW(hist_api.get_account_history_operations("commitee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 301), fc::exception); histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 200); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + BOOST_REQUIRE_EQUAL( histories.size(), 125u ); } catch (fc::exception &e) { @@ -679,32 +679,32 @@ BOOST_AUTO_TEST_CASE(api_limit_get_account_history) { create_account("bob"); generate_block(); - fc::usleep(fc::milliseconds(2000)); + fc::usleep(fc::milliseconds(100)); int asset_create_op_id = operation::tag::value; int account_create_op_id = operation::tag::value; //account_id_type() did 3 ops and includes id0 vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); // 1 account_create op larger than id1 histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 210, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK(histories[0].id.instance() != 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK(histories[0].id.instance() != 0u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // Limit 2 returns 2 result histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK(histories[1].id.instance() != 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK(histories[1].id.instance() != 0u); BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); // bob has 1 op histories = hist_api.get_account_history("bob", operation_history_id_type(), 210, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // create a bunch of accounts @@ -717,7 +717,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_account_history) { GRAPHENE_CHECK_THROW(hist_api.get_account_history("1.2.0", operation_history_id_type(), 260, operation_history_id_type()), fc::exception); histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 210, operation_history_id_type()); - BOOST_REQUIRE_EQUAL( histories.size(), 125 ); + BOOST_REQUIRE_EQUAL( histories.size(), 125u ); } catch (fc::exception &e) { edump((e.to_detail_string())); throw; @@ -732,11 +732,11 @@ BOOST_AUTO_TEST_CASE(api_limit_get_relative_account_history) { create_account("bob"); generate_block(); - fc::usleep(fc::milliseconds(2000)); + fc::usleep(fc::milliseconds(100)); GRAPHENE_CHECK_THROW(hist_api.get_relative_account_history("1.2.0", 126, 260, 0), fc::exception); vector histories = hist_api.get_relative_account_history("1.2.0", 126, 210, 0); - BOOST_REQUIRE_EQUAL( histories.size(), 0 ); + BOOST_REQUIRE_EQUAL( histories.size(), 0u ); } catch (fc::exception &e) { edump((e.to_detail_string())); @@ -746,23 +746,21 @@ BOOST_AUTO_TEST_CASE(api_limit_get_relative_account_history) { BOOST_AUTO_TEST_CASE(api_limit_get_account_history_by_operations) { try { - graphene::app::history_api hist_api(app); - vector operation_types; - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); - generate_block(); - fc::usleep(fc::milliseconds(2000)); - - GRAPHENE_CHECK_THROW(hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 260), fc::exception); - history_operation_detail histories = hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 210); - BOOST_REQUIRE_EQUAL( histories.total_count, 3 ); - + graphene::app::history_api hist_api(app); + vector operation_types; + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + generate_block(); + fc::usleep(fc::milliseconds(100)); + GRAPHENE_CHECK_THROW(hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 260), fc::exception); + history_operation_detail histories = hist_api.get_account_history_by_operations("1.2.0", operation_types, 0, 210); + BOOST_REQUIRE_EQUAL( histories.total_count, 3u ); } catch (fc::exception &e) { - edump((e.to_detail_string())); - throw; + edump((e.to_detail_string())); + throw; } } From df514accf33472831257bc48c86561bcc7b5ebb7 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 18 Mar 2019 16:37:21 -0700 Subject: [PATCH 19/20] Update asset_api_tests.cpp updated for test case to match the input type of the api after merge with develop branch --- tests/tests/asset_api_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests/asset_api_tests.cpp b/tests/tests/asset_api_tests.cpp index 230c3b5222..7536b3529a 100644 --- a/tests/tests/asset_api_tests.cpp +++ b/tests/tests/asset_api_tests.cpp @@ -76,8 +76,8 @@ BOOST_AUTO_TEST_CASE( api_limit_get_asset_holders ) transfer(account_id_type()(db), bob, asset(300)); // make call - GRAPHENE_CHECK_THROW(asset_api.get_asset_holders(asset_id_type(), 0, 260), fc::exception); - vector holders = asset_api.get_asset_holders(asset_id_type(), 0, 210); + GRAPHENE_CHECK_THROW(asset_api.get_asset_holders(std::string( static_cast(asset_id_type())), 0, 260), fc::exception); + vector holders = asset_api.get_asset_holders(std::string( static_cast(asset_id_type())), 0, 210); BOOST_REQUIRE_EQUAL( holders.size(), 4u ); } From 78cb2c7c7d4c417602ba51c0d429e3e4af408e97 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 18 Mar 2019 22:33:55 -0700 Subject: [PATCH 20/20] updated api.cpp for build failures --- libraries/app/api.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 4300e06d66..c2631b1293 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -534,14 +534,15 @@ namespace graphene { namespace app { // asset_api asset_api::asset_api(graphene::app::application& app) : - _db( *app.chain_database()), - database_api( std::ref(*app.chain_database()), &(app.get_options()) + _app(app), + _db( *app.chain_database()), + database_api( std::ref(*app.chain_database()), &(app.get_options()) ) { } asset_api::~asset_api() { } vector asset_api::get_asset_holders( std::string asset, uint32_t start, uint32_t limit ) const { - FC_ASSERT(limit <= 100); - + uint64_t api_limit_get_asset_holders=_app.get_options().api_limit_get_asset_holders; + FC_ASSERT(limit <= api_limit_get_asset_holders); asset_id_type asset_id = database_api.get_asset_id_from_string( asset ); const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );