From 07a3abec7656062f490f3f45d1e9fe6b776537e7 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Mon, 5 Aug 2019 17:24:04 +0200 Subject: [PATCH] Cleanup --- api_access.json | 12 ++++++------ libraries/app/api.cpp | 12 ++++++------ libraries/app/application.cpp | 14 +++++++------- libraries/app/application_impl.hxx | 4 ++-- libraries/app/include/graphene/app/api.hpp | 2 +- libraries/chain/account_evaluator.cpp | 2 +- .../include/graphene/chain/account_object.hpp | 2 +- libraries/fc | 2 +- tests/tests/login_signed_tests.cpp | 6 +++--- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/api_access.json b/api_access.json index 748e2e1702..71285330b5 100644 --- a/api_access.json +++ b/api_access.json @@ -1,5 +1,5 @@ { - "permission_map": + "permission_map": [ [ "*", @@ -23,26 +23,26 @@ "required_lifetime_member": false, "required_registrar": "registrar_name1", "required_referrer": "", - "allowed_apis": + "allowed_apis": [ "database_api", "history_api", "block_api", "orders_api" ] - }, + }, { "required_lifetime_member": true, "required_registrar": "registrar_name2", "required_referrer": "", - "allowed_apis": + "allowed_apis": [ "database_api", "history_api", "block_api", "orders_api" ] - } + } ], "permission_map_signed_user": [ @@ -51,7 +51,7 @@ { "required_lifetime_member": false, "required_registrar": "", - "allowed_apis": + "allowed_apis": [ "database_api", "history_api", diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c07cbabf1d..01094c5a7d 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -97,7 +97,7 @@ namespace graphene { namespace app { auto db = _app.chain_database(); int64_t offset( (trx.expiration - db->head_block_time()).to_seconds() ); if( offset > 5*60 || offset < 0 ) - return false; + return false; auto op = trx.operations[0]; if( op.which() != operation::tag::value ) // only transfer op for validation @@ -127,7 +127,7 @@ namespace graphene { namespace app { { const auto& api_access_info = api_access_info_var->get(); if( !verify_api_access_info_signed( acc, api_access_info ) ) - return false; + return false; for( const auto& api : api_access_info.allowed_apis ) enable_api( api ); @@ -141,10 +141,10 @@ namespace graphene { namespace app { { if( !verify_api_access_info_signed( acc, api_access_info ) ) continue; - + for( const auto& api : api_access_info.allowed_apis ) enable_api( api ); - + return true; } return false; @@ -156,7 +156,7 @@ namespace graphene { namespace app { { auto db = _app.chain_database(); - if( api_access_info.required_lifetime_member && !acc.is_lifetime_member() ) + if( api_access_info.required_lifetime_member && !acc.is_lifetime_member() ) return false; const auto& required_registrar_name = api_access_info.required_registrar; @@ -191,7 +191,7 @@ namespace graphene { namespace app { if( acc.original_referrer ) acc_original_referrer_name = (*acc.original_registrar)(*db).name; - has_required_referrer = required_referrer_name == acc_referrer_name + has_required_referrer = required_referrer_name == acc_referrer_name || required_referrer_name == acc_original_referrer_name; } diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 07d4140eb7..81776bc1ab 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -231,18 +231,18 @@ void application_impl::new_connection( const fc::http::websocket_connection_ptr& auto wsc = std::make_shared(c, GRAPHENE_NET_MAX_NESTED_OBJECTS); auto login = std::make_shared( std::ref(*_self) ); login->enable_api("database_api"); - + wsc->register_api(login->database()); wsc->register_api(fc::api(login)); c->set_session_data( wsc ); - + std::string username = "*"; std::string password = "*"; // Try to extract login information from "Authorization" header if present std::string auth = c->get_request_header("Authorization"); if( !boost::starts_with(auth, "Basic ") ) login->login(username, password); - + FC_ASSERT( auth.size() > 6 ); auto decoded_auth = fc::base64_decode(auth.substr(6)); @@ -257,8 +257,8 @@ void application_impl::new_connection( const fc::http::websocket_connection_ptr& password = parts[1]; login->login( username, password ); } - else - { + else + { string base64_encoded_trx = parts[1]; login->login_signed( base64_encoded_trx ); } @@ -530,12 +530,12 @@ optional< api_access_info > application_impl::get_api_access_info(const string& optional< api_access_info_signed_variant > application_impl::get_api_access_info_signed(const string& username)const { auto it = _apiaccess.permission_map_signed_user.find( username ); - if( it != _apiaccess.permission_map_signed_user.end() ) + if( it != _apiaccess.permission_map_signed_user.end() ) return it->second; if( !_apiaccess.permission_map_signed_default.empty() ) return _apiaccess.permission_map_signed_default; - + return optional< api_access_info_signed_variant >(); } diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 81ba9c1b3c..9a467a636e 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -47,14 +47,14 @@ class application_impl : public net::node_delegate fc::optional< api_access_info > get_api_access_info(const string& username)const; - fc::optional< api_access_info_signed_variant > get_api_access_info_signed(const string& username)const; + fc::optional< api_access_info_signed_variant > get_api_access_info_signed(const string& username)const; void set_api_access_info(const string& username, api_access_info&& permissions); void set_api_access_info_signed_default(std::vector&& permissions); void set_api_access_info_signed_user(const string& username, api_access_info_signed&& permissions); - + /** * If delegate has the item, the network has no need to fetch it. */ diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 0150bf7e8b..fa1f9071d3 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -585,7 +585,7 @@ namespace graphene { namespace app { optional< fc::api > _orders_api; optional< fc::api > _debug_api; - bool verify_api_access_info_signed( const account_object& acc, + bool verify_api_access_info_signed( const account_object& acc, const api_access_info_signed& api_access_info ); }; diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index ed35e4f515..ccfc233f09 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -418,7 +418,7 @@ void_result account_upgrade_evaluator::do_evaluate(const account_upgrade_evaluat void_result account_upgrade_evaluator::do_apply(const account_upgrade_evaluator::operation_type& o) { try { database& d = db(); - + d.modify(*account, [&](account_object& a) { if( o.upgrade_to_lifetime_member ) { diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 9fa45843f0..3dbb4d3559 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -186,7 +186,7 @@ namespace graphene { namespace chain { /// The account's name. This name must be unique among all account names on the graph. May not be empty. string name; - + /** * The owner authority represents absolute control over the account. Usually the keys in this authority will * be kept in cold storage, as they should not be needed very often and compromise of these keys constitutes diff --git a/libraries/fc b/libraries/fc index af572ba7d0..2c5c30848a 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit af572ba7d016136883c31daaf054e03e5f3695a1 +Subproject commit 2c5c30848a2d1cdd774ecaef2b051565f6f151f9 diff --git a/tests/tests/login_signed_tests.cpp b/tests/tests/login_signed_tests.cpp index 6fc1ddc420..89393939b0 100644 --- a/tests/tests/login_signed_tests.cpp +++ b/tests/tests/login_signed_tests.cpp @@ -48,7 +48,7 @@ BOOST_FIXTURE_TEST_SUITE( login_signed_tests, login_signed_fixture ) BOOST_AUTO_TEST_CASE( fail_with_timestamp_too_fresh ) { try { - + ACTOR( alice ); transfer_operation op; op.from = alice_id; @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE( fail_with_not_transfer_op_in_trx ) ACTOR( alice ); account_update_operation op; op.account = alice_id; - + signed_transaction trx; trx.operations.push_back( op ); trx.expiration = db.head_block_time() + 60; @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE( fail_with_empty_signature_keys ) signed_transaction trx; trx.operations.push_back( op ); trx.expiration = db.head_block_time() + 60; - + auto json = fc::json::to_string( trx ); auto encoded = fc::base64_encode( json );