From 2998d67107c6f91ad295de0e481c1433a9159174 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Tue, 12 Dec 2017 19:51:23 +0100 Subject: [PATCH 1/5] Issue #1855 partial changes, CI can fail --- .../include/steem/protocol/config.hpp | 4 +- libraries/protocol/steem_operations.cpp | 4 +- tests/db_fixture/database_fixture.cpp | 4 +- tests/db_fixture/database_fixture.hpp | 2 +- tests/tests/smt_tests.cpp | 94 ++++++++++++++++++- 5 files changed, 98 insertions(+), 10 deletions(-) diff --git a/libraries/protocol/include/steem/protocol/config.hpp b/libraries/protocol/include/steem/protocol/config.hpp index fe3b8e5d88..44ddb4997a 100644 --- a/libraries/protocol/include/steem/protocol/config.hpp +++ b/libraries/protocol/include/steem/protocol/config.hpp @@ -274,7 +274,9 @@ #ifdef STEEM_ENABLE_SMT +#define SMT_MAX_VOTABLE_ASSETS 2 #define SMT_VESTING_WITHDRAW_INTERVAL_SECONDS (60*60*24*7) /// 1 week per interval #define SMT_UPVOTE_LOCKOUT (60*60*12) /// 12 hours -#endif +#endif /// STEEM_ENABLE_SMT + diff --git a/libraries/protocol/steem_operations.cpp b/libraries/protocol/steem_operations.cpp index 4dd82ade9b..c14b917448 100644 --- a/libraries/protocol/steem_operations.cpp +++ b/libraries/protocol/steem_operations.cpp @@ -88,7 +88,9 @@ namespace steem { namespace protocol { #ifdef STEEM_ENABLE_SMT void operator()( const allowed_vote_assets& va) const { - FC_TODO("To be implemented suppport for allowed_vote_assets"); + FC_ASSERT(va.size() <= SMT_MAX_VOTABLE_ASSETS, "Too much votable assets specified"); + FC_ASSERT(va.votable_assets.find(STEEM_SYMBOL) == va.votable_assets.end(), + "STEEM cannot be explicitly specified as votable assets"); } #endif void operator()( const comment_payout_beneficiaries& cpb ) const diff --git a/tests/db_fixture/database_fixture.cpp b/tests/db_fixture/database_fixture.cpp index d6cdd0ed92..305ac7d5b4 100644 --- a/tests/db_fixture/database_fixture.cpp +++ b/tests/db_fixture/database_fixture.cpp @@ -601,11 +601,11 @@ smt_database_fixture::~smt_database_fixture() } -asset_symbol_type smt_database_fixture::create_smt( signed_transaction& tx, const string& account_name, const fc::ecc::private_key& key, +asset_symbol_type smt_database_fixture::create_smt(const string& account_name, const fc::ecc::private_key& key, uint8_t token_decimal_places ) { smt_create_operation op; - + signed_transaction tx; try { set_price_feed( price( ASSET( "1.000 TBD" ), ASSET( "1.000 TESTS" ) ) ); diff --git a/tests/db_fixture/database_fixture.hpp b/tests/db_fixture/database_fixture.hpp index 1bad79874c..6500ea2528 100644 --- a/tests/db_fixture/database_fixture.hpp +++ b/tests/db_fixture/database_fixture.hpp @@ -252,7 +252,7 @@ struct smt_database_fixture : public clean_database_fixture smt_database_fixture(); virtual ~smt_database_fixture(); - asset_symbol_type create_smt( signed_transaction& trx, const string& account_name, const fc::ecc::private_key& key, + asset_symbol_type create_smt( const string& account_name, const fc::ecc::private_key& key, uint8_t token_decimal_places ); void transfer_smt( const string& from, const string& to, const asset& steem ); diff --git a/tests/tests/smt_tests.cpp b/tests/tests/smt_tests.cpp index a8049a2636..d486f5be6c 100644 --- a/tests/tests/smt_tests.cpp +++ b/tests/tests/smt_tests.cpp @@ -558,8 +558,8 @@ BOOST_AUTO_TEST_CASE( smt_transfer_validate ) try { ACTORS( (alice) ) - signed_transaction tx; - asset_symbol_type alice_symbol = create_smt(tx, "alice", alice_private_key, 0); + + asset_symbol_type alice_symbol = create_smt("alice", alice_private_key, 0); transfer_operation op; op.from = "alice"; @@ -579,9 +579,8 @@ BOOST_AUTO_TEST_CASE( smt_transfer_apply ) ACTORS( (alice)(bob) ) // Create SMT. - signed_transaction tx, ty; - asset_symbol_type alice_symbol = create_smt(tx, "alice", alice_private_key, 0); - asset_symbol_type bob_symbol = create_smt(ty, "bob", bob_private_key, 1); + asset_symbol_type alice_symbol = create_smt("alice", alice_private_key, 0); + asset_symbol_type bob_symbol = create_smt("bob", bob_private_key, 1); // Give some SMT to creators. const account_object& alice_account = db->get_account("alice"); @@ -608,5 +607,90 @@ BOOST_AUTO_TEST_CASE( smt_transfer_apply ) FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE( comment_votable_assers_validate ) +{ + try + { + BOOST_TEST_MESSAGE( "Test Comment Votable Assets Validate" ); + ACTORS(alice); + std::array smts; + /// Create one more than limit to test negative cases + for(size_t i = 0; i < SMT_MAX_VOTABLE_ASSETS + 1; ++i) + { + asset_symbol_type alice_smt = create_smt("alice", alice_private_key, 0); + smts[i] = std::move(smt); + } + + comment_options_operation op; + + op.author = "alice"; + op.permlink = "test"; + + BOOST_TEST_MESSAGE( "--- Testing valid configuration of votable_assets" ); + allowed_vote_assets ava; + for(size_t i = 0; i < SMT_MAX_VOTABLE_ASSETS; ++i) + { + const auto& smt = smts[i]; + ava.votable_assets[smt] = votable_asset_info(10, false); + } + + op.extensions.insert( ava ); + STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); + + BOOST_TEST_MESSAGE( "--- Testing more than 100% total weight" ); + b.beneficiaries.clear(); + b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "bob" ), STEEM_1_PERCENT * 75 ) ); + b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "sam" ), STEEM_1_PERCENT * 75 ) ); + op.extensions.clear(); + op.extensions.insert( b ); + STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); + + BOOST_TEST_MESSAGE( "--- Testing maximum number of routes" ); + b.beneficiaries.clear(); + for( size_t i = 0; i < 127; i++ ) + { + b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "foo" + fc::to_string( i ) ), 1 ) ); + } + + op.extensions.clear(); + std::sort( b.beneficiaries.begin(), b.beneficiaries.end() ); + op.extensions.insert( b ); + op.validate(); + + BOOST_TEST_MESSAGE( "--- Testing one too many routes" ); + b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "bar" ), 1 ) ); + std::sort( b.beneficiaries.begin(), b.beneficiaries.end() ); + op.extensions.clear(); + op.extensions.insert( b ); + STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); + + + BOOST_TEST_MESSAGE( "--- Testing duplicate accounts" ); + b.beneficiaries.clear(); + b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT * 2 ) ); + b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT ) ); + op.extensions.clear(); + op.extensions.insert( b ); + STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); + + BOOST_TEST_MESSAGE( "--- Testing incorrect account sort order" ); + b.beneficiaries.clear(); + b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT ) ); + b.beneficiaries.push_back( beneficiary_route_type( "alice", STEEM_1_PERCENT ) ); + op.extensions.clear(); + op.extensions.insert( b ); + STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); + + BOOST_TEST_MESSAGE( "--- Testing correct account sort order" ); + b.beneficiaries.clear(); + b.beneficiaries.push_back( beneficiary_route_type( "alice", STEEM_1_PERCENT ) ); + b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT ) ); + op.extensions.clear(); + op.extensions.insert( b ); + op.validate(); + } + FC_LOG_AND_RETHROW() +} + BOOST_AUTO_TEST_SUITE_END() #endif From c1fd1d832dcc191efffdea3ed03a106f9e7ed920 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Tue, 12 Dec 2017 21:50:26 +0100 Subject: [PATCH 2/5] Issue #1855 - implemented validation - Added helper methods to simplify `allowed_vote_assets` usage. - Added dedicated validation tests - Removed annoying warning message from database.cpp --- libraries/chain/database.cpp | 2 +- .../steem/protocol/steem_operations.hpp | 56 ++++++++ libraries/protocol/steem_operations.cpp | 4 +- tests/tests/smt_tests.cpp | 121 +++++++++--------- 4 files changed, 116 insertions(+), 67 deletions(-) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 0a7aa1ca9d..0e9a53a120 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -3463,7 +3463,7 @@ void database::adjust_smt_balance( const account_name_type& a, const asset& delt if( delta.amount.value == 0 ) return; - const auto& new_balance = create< smt_balance_object_type >( [&]( smt_balance_object_type& smt_balance ) + create< smt_balance_object_type >( [&]( smt_balance_object_type& smt_balance ) { smt_balance.owner = a; smt_balance.balance = delta; diff --git a/libraries/protocol/include/steem/protocol/steem_operations.hpp b/libraries/protocol/include/steem/protocol/steem_operations.hpp index c7e5504d2c..639b56fadf 100644 --- a/libraries/protocol/include/steem/protocol/steem_operations.hpp +++ b/libraries/protocol/include/steem/protocol/steem_operations.hpp @@ -101,6 +101,10 @@ namespace steem { namespace protocol { #ifdef STEEM_ENABLE_SMT struct votable_asset_info_v1 { + votable_asset_info_v1() = default; + votable_asset_info_v1(const share_type& max_payout, bool allow_rewards) : + max_accepted_payout(max_payout), allow_curation_rewards(allow_rewards) {} + share_type max_accepted_payout = 0; bool allow_curation_rewards = false; }; @@ -113,7 +117,59 @@ namespace steem { namespace protocol { */ struct allowed_vote_assets { + /// Helper method to simplify construction of votable_asset_info. + void add_votable_asset(const asset_symbol_type& symbol, const share_type& max_accepted_payout, + bool allow_curation_rewards) + { + votable_asset_info info(votable_asset_info_v1(max_accepted_payout, allow_curation_rewards)); + votable_assets[symbol] = std::move(info); + } + + /** Allows to check if given symbol is allowed votable asset. + * @param symbol - asset symbol to be check against votable feature + * @param max_accepted_payout - optional output parameter which allows to take `max_accepted_payout` + * configured for given asset + * @param allow_curation_rewards - optional output parameter which allows to take `allow_curation_rewards` + * specified for given votable asset. + * @returns true if given asset is allowed votable asset for given comment. + */ + bool is_allowed(const asset_symbol_type& symbol, share_type* max_accepted_payout = nullptr, + bool* allow_curation_rewards = nullptr) const + { + auto foundI = votable_assets.find(symbol); + if(foundI == votable_assets.end()) + { + if(max_accepted_payout != nullptr) + *max_accepted_payout = 0; + if(allow_curation_rewards != nullptr) + *allow_curation_rewards = false; + return false; + } + + if(max_accepted_payout != nullptr) + *max_accepted_payout = foundI->second.get().max_accepted_payout; + if(allow_curation_rewards != nullptr) + *allow_curation_rewards = foundI->second.get().allow_curation_rewards; + + return true; + } + + /** Part of `comment_option_operation` validation process, to be called when allowed_vote_assets object + * has been added as comment option extension. + * @throws fc::assert_exception on failure. + */ + void validate() const + { + FC_ASSERT(votable_assets.size() <= SMT_MAX_VOTABLE_ASSETS, "Too much votable assets specified"); + FC_ASSERT(is_allowed(STEEM_SYMBOL) == false, + "STEEM can not be explicitly specified as one of allowed_vote_assets"); + } + + private: flat_map< asset_symbol_type, votable_asset_info > votable_assets; + + template + friend struct fc::reflector; }; #endif /// STEEM_ENABLE_SMT diff --git a/libraries/protocol/steem_operations.cpp b/libraries/protocol/steem_operations.cpp index c14b917448..173ac2239f 100644 --- a/libraries/protocol/steem_operations.cpp +++ b/libraries/protocol/steem_operations.cpp @@ -88,9 +88,7 @@ namespace steem { namespace protocol { #ifdef STEEM_ENABLE_SMT void operator()( const allowed_vote_assets& va) const { - FC_ASSERT(va.size() <= SMT_MAX_VOTABLE_ASSETS, "Too much votable assets specified"); - FC_ASSERT(va.votable_assets.find(STEEM_SYMBOL) == va.votable_assets.end(), - "STEEM cannot be explicitly specified as votable assets"); + va.validate(); } #endif void operator()( const comment_payout_beneficiaries& cpb ) const diff --git a/tests/tests/smt_tests.cpp b/tests/tests/smt_tests.cpp index d486f5be6c..a853498abb 100644 --- a/tests/tests/smt_tests.cpp +++ b/tests/tests/smt_tests.cpp @@ -612,82 +612,77 @@ BOOST_AUTO_TEST_CASE( comment_votable_assers_validate ) try { BOOST_TEST_MESSAGE( "Test Comment Votable Assets Validate" ); - ACTORS(alice); + ACTORS((alice)); std::array smts; /// Create one more than limit to test negative cases for(size_t i = 0; i < SMT_MAX_VOTABLE_ASSETS + 1; ++i) { - asset_symbol_type alice_smt = create_smt("alice", alice_private_key, 0); + asset_symbol_type smt = create_smt("alice", alice_private_key, 0); smts[i] = std::move(smt); } - comment_options_operation op; - - op.author = "alice"; - op.permlink = "test"; - - BOOST_TEST_MESSAGE( "--- Testing valid configuration of votable_assets" ); - allowed_vote_assets ava; - for(size_t i = 0; i < SMT_MAX_VOTABLE_ASSETS; ++i) { - const auto& smt = smts[i]; - ava.votable_assets[smt] = votable_asset_info(10, false); + comment_options_operation op; + + op.author = "alice"; + op.permlink = "test"; + + BOOST_TEST_MESSAGE( "--- Testing valid configuration: no votable_assets" ); + allowed_vote_assets ava; + op.extensions.insert( ava ); + op.validate(); } - - op.extensions.insert( ava ); - STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); - - BOOST_TEST_MESSAGE( "--- Testing more than 100% total weight" ); - b.beneficiaries.clear(); - b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "bob" ), STEEM_1_PERCENT * 75 ) ); - b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "sam" ), STEEM_1_PERCENT * 75 ) ); - op.extensions.clear(); - op.extensions.insert( b ); - STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); - - BOOST_TEST_MESSAGE( "--- Testing maximum number of routes" ); - b.beneficiaries.clear(); - for( size_t i = 0; i < 127; i++ ) + { - b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "foo" + fc::to_string( i ) ), 1 ) ); + comment_options_operation op; + + op.author = "alice"; + op.permlink = "test"; + + BOOST_TEST_MESSAGE( "--- Testing valid configuration of votable_assets" ); + allowed_vote_assets ava; + for(size_t i = 0; i < SMT_MAX_VOTABLE_ASSETS; ++i) + { + const auto& smt = smts[i]; + ava.add_votable_asset(smt, share_type(10 + i), (i & 2) != 0); + } + + op.extensions.insert( ava ); + op.validate(); } - op.extensions.clear(); - std::sort( b.beneficiaries.begin(), b.beneficiaries.end() ); - op.extensions.insert( b ); - op.validate(); + { + comment_options_operation op; + + op.author = "alice"; + op.permlink = "test"; + + BOOST_TEST_MESSAGE( "--- Testing invalid configuration of votable_assets - too much assets specified" ); + allowed_vote_assets ava; + for(size_t i = 0; i < smts.size(); ++i) + { + const auto& smt = smts[i]; + ava.add_votable_asset(smt, share_type(20 + i), (i & 2) != 0); + } + + op.extensions.insert( ava ); + STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); + } - BOOST_TEST_MESSAGE( "--- Testing one too many routes" ); - b.beneficiaries.push_back( beneficiary_route_type( account_name_type( "bar" ), 1 ) ); - std::sort( b.beneficiaries.begin(), b.beneficiaries.end() ); - op.extensions.clear(); - op.extensions.insert( b ); - STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); - - - BOOST_TEST_MESSAGE( "--- Testing duplicate accounts" ); - b.beneficiaries.clear(); - b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT * 2 ) ); - b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT ) ); - op.extensions.clear(); - op.extensions.insert( b ); - STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); - - BOOST_TEST_MESSAGE( "--- Testing incorrect account sort order" ); - b.beneficiaries.clear(); - b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT ) ); - b.beneficiaries.push_back( beneficiary_route_type( "alice", STEEM_1_PERCENT ) ); - op.extensions.clear(); - op.extensions.insert( b ); - STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); - - BOOST_TEST_MESSAGE( "--- Testing correct account sort order" ); - b.beneficiaries.clear(); - b.beneficiaries.push_back( beneficiary_route_type( "alice", STEEM_1_PERCENT ) ); - b.beneficiaries.push_back( beneficiary_route_type( "bob", STEEM_1_PERCENT ) ); - op.extensions.clear(); - op.extensions.insert( b ); - op.validate(); + { + comment_options_operation op; + + op.author = "alice"; + op.permlink = "test"; + + BOOST_TEST_MESSAGE( "--- Testing invalid configuration of votable_assets - STEEM added to container" ); + allowed_vote_assets ava; + const auto& smt = smts.front(); + ava.add_votable_asset(smt, share_type(20), false); + ava.add_votable_asset(STEEM_SYMBOL, share_type(20), true); + op.extensions.insert( ava ); + STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception ); + } } FC_LOG_AND_RETHROW() } From 8c3bbea97fd66d4279cf0068af77a8d51bd132d9 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Tue, 12 Dec 2017 22:23:57 +0100 Subject: [PATCH 3/5] Issue #1855 get_config.cpp supplemented by definition of SMT_MAX_VOTABLE_ASSETS --- libraries/protocol/get_config.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/protocol/get_config.cpp b/libraries/protocol/get_config.cpp index 95b27ca273..67635bc550 100644 --- a/libraries/protocol/get_config.cpp +++ b/libraries/protocol/get_config.cpp @@ -19,6 +19,7 @@ fc::variant_object get_config() result[ "STEEM_ENABLE_SMT" ] = true; result["SMT_VESTING_WITHDRAW_INTERVAL_SECONDS"] = SMT_VESTING_WITHDRAW_INTERVAL_SECONDS; result["SMT_UPVOTE_LOCKOUT"] = SMT_UPVOTE_LOCKOUT; + result["SMT_MAX_VOTABLE_ASSETS"] = SMT_MAX_VOTABLE_ASSETS; #else result[ "STEEM_ENABLE_SMT" ] = false; #endif From ef4b2693a23402af4d4662dbd9f13b24ba8313ef Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Thu, 14 Dec 2017 15:18:27 +0100 Subject: [PATCH 4/5] Issue #1855 Renamed `votable_assets` member variable to `_votable_assets`. --- .../include/steem/protocol/steem_operations.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/protocol/include/steem/protocol/steem_operations.hpp b/libraries/protocol/include/steem/protocol/steem_operations.hpp index 639b56fadf..fcbebadefd 100644 --- a/libraries/protocol/include/steem/protocol/steem_operations.hpp +++ b/libraries/protocol/include/steem/protocol/steem_operations.hpp @@ -122,7 +122,7 @@ namespace steem { namespace protocol { bool allow_curation_rewards) { votable_asset_info info(votable_asset_info_v1(max_accepted_payout, allow_curation_rewards)); - votable_assets[symbol] = std::move(info); + _votable_assets[symbol] = std::move(info); } /** Allows to check if given symbol is allowed votable asset. @@ -136,8 +136,8 @@ namespace steem { namespace protocol { bool is_allowed(const asset_symbol_type& symbol, share_type* max_accepted_payout = nullptr, bool* allow_curation_rewards = nullptr) const { - auto foundI = votable_assets.find(symbol); - if(foundI == votable_assets.end()) + auto foundI = _votable_assets.find(symbol); + if(foundI == _votable_assets.end()) { if(max_accepted_payout != nullptr) *max_accepted_payout = 0; @@ -160,13 +160,13 @@ namespace steem { namespace protocol { */ void validate() const { - FC_ASSERT(votable_assets.size() <= SMT_MAX_VOTABLE_ASSETS, "Too much votable assets specified"); + FC_ASSERT(_votable_assets.size() <= SMT_MAX_VOTABLE_ASSETS, "Too much votable assets specified"); FC_ASSERT(is_allowed(STEEM_SYMBOL) == false, "STEEM can not be explicitly specified as one of allowed_vote_assets"); } private: - flat_map< asset_symbol_type, votable_asset_info > votable_assets; + flat_map< asset_symbol_type, votable_asset_info > _votable_assets; template friend struct fc::reflector; @@ -1102,7 +1102,7 @@ FC_REFLECT( steem::protocol::comment_payout_beneficiaries, (beneficiaries) ) #ifdef STEEM_ENABLE_SMT FC_REFLECT( steem::protocol::votable_asset_info_v1, (max_accepted_payout)(allow_curation_rewards) ) -FC_REFLECT( steem::protocol::allowed_vote_assets, (votable_assets) ) +FC_REFLECT( steem::protocol::allowed_vote_assets, (_votable_assets) ) #endif FC_REFLECT_TYPENAME( steem::protocol::comment_options_extension ) From bfeb72e84b4f0da959d2a59f5ca11c31b8b89845 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Thu, 28 Dec 2017 12:33:44 +0100 Subject: [PATCH 5/5] Issue #1855 _votable_assets renamed to votable_assets, removed private access. --- .../include/steem/protocol/steem_operations.hpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libraries/protocol/include/steem/protocol/steem_operations.hpp b/libraries/protocol/include/steem/protocol/steem_operations.hpp index fcbebadefd..4031059d68 100644 --- a/libraries/protocol/include/steem/protocol/steem_operations.hpp +++ b/libraries/protocol/include/steem/protocol/steem_operations.hpp @@ -122,7 +122,7 @@ namespace steem { namespace protocol { bool allow_curation_rewards) { votable_asset_info info(votable_asset_info_v1(max_accepted_payout, allow_curation_rewards)); - _votable_assets[symbol] = std::move(info); + votable_assets[symbol] = std::move(info); } /** Allows to check if given symbol is allowed votable asset. @@ -136,8 +136,8 @@ namespace steem { namespace protocol { bool is_allowed(const asset_symbol_type& symbol, share_type* max_accepted_payout = nullptr, bool* allow_curation_rewards = nullptr) const { - auto foundI = _votable_assets.find(symbol); - if(foundI == _votable_assets.end()) + auto foundI = votable_assets.find(symbol); + if(foundI == votable_assets.end()) { if(max_accepted_payout != nullptr) *max_accepted_payout = 0; @@ -160,16 +160,12 @@ namespace steem { namespace protocol { */ void validate() const { - FC_ASSERT(_votable_assets.size() <= SMT_MAX_VOTABLE_ASSETS, "Too much votable assets specified"); + FC_ASSERT(votable_assets.size() <= SMT_MAX_VOTABLE_ASSETS, "Too much votable assets specified"); FC_ASSERT(is_allowed(STEEM_SYMBOL) == false, "STEEM can not be explicitly specified as one of allowed_vote_assets"); } - private: - flat_map< asset_symbol_type, votable_asset_info > _votable_assets; - - template - friend struct fc::reflector; + flat_map< asset_symbol_type, votable_asset_info > votable_assets; }; #endif /// STEEM_ENABLE_SMT @@ -1102,7 +1098,7 @@ FC_REFLECT( steem::protocol::comment_payout_beneficiaries, (beneficiaries) ) #ifdef STEEM_ENABLE_SMT FC_REFLECT( steem::protocol::votable_asset_info_v1, (max_accepted_payout)(allow_curation_rewards) ) -FC_REFLECT( steem::protocol::allowed_vote_assets, (_votable_assets) ) +FC_REFLECT( steem::protocol::allowed_vote_assets, (votable_assets) ) #endif FC_REFLECT_TYPENAME( steem::protocol::comment_options_extension )