diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 0b94264bd2..e575576ed0 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -239,6 +240,8 @@ namespace detail { void startup() { try { _max_block_age =_options->at("max-block-age").as(); + _shared_file_size = fc::parse_size( _options->at( "shared-file-size" ).as< string >() ); + ilog( "shared_file_size is ${n} bytes", ("n", _shared_file_size) ); register_builtin_apis(); if( _options->count("resync-blockchain") ) @@ -260,13 +263,13 @@ namespace detail { if( _options->count("replay-blockchain") ) { ilog("Replaying blockchain on user request."); - _chain_db->reindex( _data_dir / "blockchain", _options->at( "shared-file-size" ).as< uint64_t >() ); + _chain_db->reindex( _data_dir / "blockchain", _shared_file_size ); } else { try { - _chain_db->open(_data_dir / "blockchain", 0, _options->at( "shared-file-size" ).as< uint64_t >() ); + _chain_db->open(_data_dir / "blockchain", 0, _shared_file_size ); } catch( fc::assert_exception& ) { @@ -274,12 +277,12 @@ namespace detail { try { - _chain_db->reindex( _data_dir / "blockchain", _options->at( "shared-file-size" ).as< uint64_t >() ); + _chain_db->reindex( _data_dir / "blockchain", _shared_file_size ); } catch( chain::block_log_exception& ) { wlog( "Error opening block log. Having to resync from network..." ); - _chain_db->open( _data_dir / "blockchain", 0, _options->at( "shared-file-size" ).as< uint64_t >() ); + _chain_db->open( _data_dir / "blockchain", 0, _shared_file_size ); } } } @@ -863,7 +866,7 @@ void application::set_program_options(boost::program_options::options_descriptio ("p2p-max-connections", bpo::value(), "Maxmimum number of incoming connections on P2P endpoint") ("seed-node,s", bpo::value>()->composing(), "P2P nodes to connect to on startup (may specify multiple times)") ("checkpoint,c", bpo::value>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.") - ("shared-file-size", bpo::value()->default_value(34359738368), "Size of the shared memory file. Default: 34359738368 (32GB)") + ("shared-file-size", bpo::value()->default_value("32G"), "Size of the shared memory file. Default: 32G") ("rpc-endpoint", bpo::value()->implicit_value("127.0.0.1:8090"), "Endpoint for websocket RPC to listen on") ("rpc-tls-endpoint", bpo::value()->implicit_value("127.0.0.1:8089"), "Endpoint for TLS websocket RPC to listen on") ("server-pem,p", bpo::value()->implicit_value("server.pem"), "The TLS certificate file for this server") diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 2c7d950544..672839392d 100755 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -965,6 +965,9 @@ void database_api::set_pending_payout( discussion& d )const } } + if( d.parent_author != STEEMIT_ROOT_POST_PARENT ) + d.cashout_time = my->_db.calculate_discussion_payout_time( my->_db.get< comment_object >( d.id ) ); + if( d.body.size() > 1024*128 ) d.body = "body pruned due to size"; if( d.parent_author.size() > 0 && d.body.size() > 1024*16 ) @@ -1057,17 +1060,31 @@ map< uint32_t, applied_operation > database_api::get_account_history( string acc return result; } -vector database_api::get_trending_tags( string after, uint32_t limit )const { - vector result; - const auto& tags_stats_idx = my->_db.get_index().indices().get(); - auto itr = tags_stats_idx.lower_bound(after); +vector database_api::get_trending_tags( string after, uint32_t limit )const +{ + limit = std::min( limit, uint32_t(100) ); + vector result; + result.reserve( limit ); - while( itr != tags_stats_idx.end() && limit > 0 ) { - result.push_back(*itr); - --limit; ++itr; - } + const auto& nidx = my->_db.get_index().indices().get(); - return result; + const auto& ridx = my->_db.get_index().indices().get(); + auto itr = ridx.begin(); + if( after != "" && nidx.size() ) + { + auto nitr = nidx.lower_bound( after ); + if( nitr == nidx.end() ) + itr = ridx.end(); + else + itr = ridx.iterator_to( *nitr ); + } + + while( itr != ridx.end() && result.size() < limit ) + { + result.push_back( *itr ); + ++itr; + } + return result; } discussion database_api::get_discussion( comment_id_type id )const { @@ -1566,12 +1583,12 @@ state database_api::get_state( string path )const path = "trending"; /// FETCH CATEGORY STATE - auto trending_cat = get_trending_categories( "", 100 ); - for( const auto& c : trending_cat ) + auto trending_tags = get_trending_tags( "", 100 ); + for( const auto& t : trending_tags ) { - string name = c.name; - _state.category_idx.trending.push_back( name ); - _state.categories[ name ] = category_api_obj( c ); + string name = t.name; + _state.tag_idx.trending.push_back( name ); + _state.tags[ name ] = t; } auto best_cat = get_best_categories( "", 50 ); for( const auto& c : best_cat ) @@ -1660,14 +1677,14 @@ state database_api::get_state( string path )const int count = 0; const auto& pidx = my->_db.get_index().indices().get(); auto itr = pidx.lower_bound( acnt ); - eacnt.posts = vector(); + eacnt.comments = vector(); while( itr != pidx.end() && itr->author == acnt && count < 20 ) { if( itr->parent_author.size() ) { const auto link = acnt + "/" + to_string( itr->permlink ); - eacnt.posts->push_back( link ); + eacnt.comments->push_back( link ); _state.content[ link ] = *itr; set_pending_payout( _state.content[ link ] ); ++count; diff --git a/libraries/app/include/steemit/app/database_api.hpp b/libraries/app/include/steemit/app/database_api.hpp index ab2adfa600..aa97834272 100755 --- a/libraries/app/include/steemit/app/database_api.hpp +++ b/libraries/app/include/steemit/app/database_api.hpp @@ -121,7 +121,7 @@ class database_api */ void cancel_all_subscriptions(); - vector get_trending_tags( string after_tag, uint32_t limit )const; + vector get_trending_tags( string after_tag, uint32_t limit )const; /** * This API is a short-cut for returning all of the state required for a particular URL diff --git a/libraries/app/include/steemit/app/state.hpp b/libraries/app/include/steemit/app/state.hpp index 4f1058880e..328b1ec78a 100644 --- a/libraries/app/include/steemit/app/state.hpp +++ b/libraries/app/include/steemit/app/state.hpp @@ -38,12 +38,16 @@ namespace steemit { namespace app { struct category_index { - vector< string > trending; /// pending payouts vector< string > active; /// recent activity vector< string > recent; /// recently created vector< string > best; /// total lifetime payout }; + struct tag_index + { + vector< string > trending; /// pending payouts + }; + struct vote_state { string voter; @@ -97,7 +101,7 @@ namespace steemit { namespace app { set witness_votes; optional> open_orders; - optional> posts; /// permlinks for this user + optional> comments; /// permlinks for this user optional> blog; /// blog posts for this user optional> feed; /// feed posts for this user optional> recent_replies; /// blog posts for this user @@ -151,12 +155,16 @@ namespace steemit { namespace app { */ app::category_index category_idx; + app::tag_index tag_idx; + /** * "" is the global discussion index, otherwise the indicies are ranked by category */ map discussion_idx; map< string, category_api_obj > categories; + map< string, tag_api_obj > tags; + /** * map from account/slug to full nested discussion */ @@ -179,17 +187,18 @@ namespace steemit { namespace app { FC_REFLECT_DERIVED( steemit::app::extended_account, (steemit::app::account_api_obj), (vesting_balance)(reputation) - (transfer_history)(market_history)(post_history)(vote_history)(other_history)(witness_votes)(open_orders)(posts)(feed)(blog)(recent_replies)(blog_category)(recommended) ) + (transfer_history)(market_history)(post_history)(vote_history)(other_history)(witness_votes)(open_orders)(comments)(feed)(blog)(recent_replies)(blog_category)(recommended) ) FC_REFLECT( steemit::app::vote_state, (voter)(weight)(rshares)(percent)(reputation)(time) ); FC_REFLECT( steemit::app::account_vote, (authorperm)(weight)(rshares)(percent)(time) ); FC_REFLECT( steemit::app::discussion_index, (category)(trending)(trending30)(updated)(created)(responses)(active)(votes)(maturing)(best)(hot)(promoted)(cashout) ) -FC_REFLECT( steemit::app::category_index, (trending)(active)(recent)(best) ) +FC_REFLECT( steemit::app::category_index, (active)(recent)(best) ) +FC_REFLECT( steemit::app::tag_index, (trending) ) FC_REFLECT_DERIVED( steemit::app::discussion, (steemit::app::comment_api_obj), (url)(root_title)(pending_payout_value)(total_pending_payout_value)(active_votes)(replies)(author_reputation)(promoted)(first_reblogged_by)(first_reblogged_on) ) -FC_REFLECT( steemit::app::state, (current_route)(props)(category_idx)(categories)(content)(accounts)(pow_queue)(witnesses)(discussion_idx)(witness_schedule)(feed_price)(error)(market_data) ) +FC_REFLECT( steemit::app::state, (current_route)(props)(category_idx)(tag_idx)(categories)(tags)(content)(accounts)(pow_queue)(witnesses)(discussion_idx)(witness_schedule)(feed_price)(error)(market_data) ) FC_REFLECT_DERIVED( steemit::app::extended_limit_order, (steemit::app::limit_order_api_obj), (real_price)(rewarded) ) FC_REFLECT( steemit::app::order_history_item, (time)(type)(sbd_quantity)(steem_quantity)(real_price) ); diff --git a/libraries/app/include/steemit/app/steem_api_objects.hpp b/libraries/app/include/steemit/app/steem_api_objects.hpp index 59aea34b79..6b6e30b9a6 100644 --- a/libraries/app/include/steemit/app/steem_api_objects.hpp +++ b/libraries/app/include/steemit/app/steem_api_objects.hpp @@ -8,6 +8,8 @@ #include #include +#include + namespace steemit { namespace app { using namespace steemit::chain; @@ -160,6 +162,26 @@ struct category_api_obj time_point_sec last_update; }; +struct tag_api_obj +{ + tag_api_obj( const tags::tag_stats_object& o ) : + name( o.tag ), + total_children_rshares2(o.total_children_rshares2), + total_payouts(o.total_payout), + net_votes(o.net_votes), + top_posts(o.top_posts), + comments(o.comments) {} + + tag_api_obj() {} + + string name; + fc::uint128_t total_children_rshares2; + asset total_payouts; + int32_t net_votes = 0; + uint32_t top_posts = 0; + uint32_t comments = 0; +}; + struct account_api_obj { account_api_obj( const chain::account_object& a, const chain::account_authority_object& auth ) : @@ -483,6 +505,15 @@ FC_REFLECT( steemit::app::feed_history_api_obj, (price_history) ) +FC_REFLECT( steemit::app::tag_api_obj, + (name) + (total_children_rshares2) + (total_payouts) + (net_votes) + (top_posts) + (comments) + ) + FC_REFLECT( steemit::app::witness_api_obj, (id) (owner) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 54eff82eb3..a02b08e41c 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -2057,6 +2057,8 @@ void database::cashout_comment_helper( const comment_object& comment ) c.last_payout = head_block_time(); } ); + push_virtual_operation( comment_payout_update_operation( comment.author, to_string( comment.permlink ) ) ); + const auto& vote_idx = get_index< comment_vote_index >().indices().get< by_comment_voter >(); auto vote_itr = vote_idx.lower_bound( comment.id ); while( vote_itr != vote_idx.end() && vote_itr->comment == comment.id ) diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index a6c5718b16..c82fe18363 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -33,7 +33,7 @@ namespace steemit { namespace chain { inline void validate_permlink_0_1( const string& permlink ) { - FC_ASSERT( permlink.size() > STEEMIT_MIN_PERMLINK_LENGTH && permlink.size() < STEEMIT_MAX_PERMLINK_LENGTH, "permlink is not a valid size" ); + FC_ASSERT( permlink.size() > STEEMIT_MIN_PERMLINK_LENGTH && permlink.size() < STEEMIT_MAX_PERMLINK_LENGTH, "Permlink is not a valid size." ); for( auto c : permlink ) { @@ -65,7 +65,7 @@ void witness_update_evaluator::do_apply( const witness_update_operation& o ) if ( db().has_hardfork( STEEMIT_HARDFORK_0_1 ) ) { - FC_ASSERT( o.url.size() <= STEEMIT_MAX_WITNESS_URL_LENGTH, "url is too long" ); + FC_ASSERT( o.url.size() <= STEEMIT_MAX_WITNESS_URL_LENGTH, "URL is too long" ); } else if( o.url.size() > STEEMIT_MAX_WITNESS_URL_LENGTH ) { @@ -111,11 +111,11 @@ void account_create_evaluator::do_apply( const account_create_operation& o ) const auto& props = db().get_dynamic_global_properties(); - FC_ASSERT( creator.balance >= o.fee, "Insufficient balance to create account", ( "creator.balance", creator.balance )( "required", o.fee ) ); + FC_ASSERT( creator.balance >= o.fee, "Insufficient balance to create account.", ( "creator.balance", creator.balance )( "required", o.fee ) ); if( db().has_hardfork( STEEMIT_HARDFORK_0_1 ) ) { const witness_schedule_object& wso = db().get_witness_schedule_object(); - FC_ASSERT( o.fee >= wso.median_props.account_creation_fee, "Insufficient Fee: ${f} required, ${p} provided", + FC_ASSERT( o.fee >= wso.median_props.account_creation_fee, "Insufficient Fee: ${f} required, ${p} provided.", ("f", wso.median_props.account_creation_fee) ("p", o.fee) ); } @@ -177,7 +177,7 @@ void account_create_evaluator::do_apply( const account_create_operation& o ) void account_update_evaluator::do_apply( const account_update_operation& o ) { - if( db().has_hardfork( STEEMIT_HARDFORK_0_1 ) ) FC_ASSERT( o.account != STEEMIT_TEMP_ACCOUNT, "cannot update temp account" ); + if( db().has_hardfork( STEEMIT_HARDFORK_0_1 ) ) FC_ASSERT( o.account != STEEMIT_TEMP_ACCOUNT, "Cannot update temp account." ); if( ( db().has_hardfork( STEEMIT_HARDFORK_0_15__465 ) || db().is_producing() ) && o.posting ) // TODO: Add HF 15 o.posting->validate(); @@ -189,7 +189,7 @@ void account_update_evaluator::do_apply( const account_update_operation& o ) { #ifndef IS_TEST_NET if( db().has_hardfork( STEEMIT_HARDFORK_0_11 ) ) - FC_ASSERT( db().head_block_time() - account_auth.last_owner_update > STEEMIT_OWNER_UPDATE_LIMIT, "can only update owner authority once a minute" ); + FC_ASSERT( db().head_block_time() - account_auth.last_owner_update > STEEMIT_OWNER_UPDATE_LIMIT, "Owner authority can only be updated once a minute." ); #endif if( ( db().has_hardfork( STEEMIT_HARDFORK_0_15__465 ) || db().is_producing() ) ) // TODO: Add HF 15 @@ -258,14 +258,14 @@ void delete_comment_evaluator::do_apply( const delete_comment_operation& o ) { if( db().has_hardfork( STEEMIT_HARDFORK_0_10 ) ) { const auto& auth = db().get_account( o.author ); - FC_ASSERT( !(auth.owner_challenged || auth.active_challenged ), "cannot process operation because account is currently challenged" ); + FC_ASSERT( !(auth.owner_challenged || auth.active_challenged ), "Operation cannot be processed because account is currently challenged." ); } const auto& comment = db().get_comment( o.author, o.permlink ); - FC_ASSERT( comment.children == 0, "comment cannot have any replies" ); + FC_ASSERT( comment.children == 0, "Cannot delete a comment with replies." ); if( db().is_producing() ) { - FC_ASSERT( comment.net_rshares <= 0, "comment cannot have any net positive votes" ); + FC_ASSERT( comment.net_rshares <= 0, "Cannot delete a comment with net positive votes." ); } if( comment.net_rshares > 0 ) return; @@ -314,19 +314,19 @@ void comment_options_evaluator::do_apply( const comment_options_operation& o ) if( db().has_hardfork( STEEMIT_HARDFORK_0_10 ) ) { const auto& auth = db().get_account( o.author ); - FC_ASSERT( !(auth.owner_challenged || auth.active_challenged ), "cannot process operation because account is currently challenged" ); + FC_ASSERT( !(auth.owner_challenged || auth.active_challenged ), "Operation cannot be processed because account is currently challenged." ); } const auto& comment = db().get_comment( o.author, o.permlink ); if( !o.allow_curation_rewards || !o.allow_votes || o.max_accepted_payout < comment.max_accepted_payout ) - FC_ASSERT( comment.abs_rshares == 0, "operations contains options that are only updatedable on an account with no rshares" ); + FC_ASSERT( comment.abs_rshares == 0, "One of the included comment options requires the comment to have no rshares allocated to it." ); - FC_ASSERT( o.extensions.size() == 0, "extensions are not currently supported" ); - FC_ASSERT( comment.allow_curation_rewards >= o.allow_curation_rewards, "cannot re-enable curation rewards" ); - FC_ASSERT( comment.allow_votes >= o.allow_votes, "cannot re-enable votes" ); - FC_ASSERT( comment.max_accepted_payout >= o.max_accepted_payout, "cannot accept a greater payout" ); - FC_ASSERT( comment.percent_steem_dollars >= o.percent_steem_dollars, "cannot accept a greater percent Steem Dollars" ); + FC_ASSERT( o.extensions.size() == 0, "Operation extensions for the comment_options_operation are not currently supported." ); + FC_ASSERT( comment.allow_curation_rewards >= o.allow_curation_rewards, "Curation rewards cannot be re-enabled." ); + FC_ASSERT( comment.allow_votes >= o.allow_votes, "Voting cannot be re-enabled." ); + FC_ASSERT( comment.max_accepted_payout >= o.max_accepted_payout, "A comment cannot accept a greater payout." ); + FC_ASSERT( comment.percent_steem_dollars >= o.percent_steem_dollars, "A comment cannot accept a greater percent SBD." ); db().modify( comment, [&]( comment_object& c ) { c.max_accepted_payout = o.max_accepted_payout; @@ -338,7 +338,7 @@ void comment_options_evaluator::do_apply( const comment_options_operation& o ) void comment_evaluator::do_apply( const comment_operation& o ) { try { if( db().is_producing() || db().has_hardfork( STEEMIT_HARDFORK_0_5__55 ) ) - FC_ASSERT( o.title.size() + o.body.size() + o.json_metadata.size(), "something should change" ); + FC_ASSERT( o.title.size() + o.body.size() + o.json_metadata.size(), "Cannot update comment because nothing appears to be changing." ); const auto& by_permlink_idx = db().get_index< comment_index >().indices().get< by_permlink >(); auto itr = by_permlink_idx.find( boost::make_tuple( o.author, o.permlink ) ); @@ -346,14 +346,14 @@ void comment_evaluator::do_apply( const comment_operation& o ) const auto& auth = db().get_account( o.author ); /// prove it exists if( db().has_hardfork( STEEMIT_HARDFORK_0_10 ) ) - FC_ASSERT( !(auth.owner_challenged || auth.active_challenged ), "cannot process operation because account is currently challenged" ); + FC_ASSERT( !(auth.owner_challenged || auth.active_challenged ), "Operation cannot be processed because account is currently challenged." ); comment_id_type id; const comment_object* parent = nullptr; if( o.parent_author != STEEMIT_ROOT_POST_PARENT ) { parent = &db().get_comment( o.parent_author, o.parent_permlink ); - FC_ASSERT( parent->depth < STEEMIT_MAX_COMMENT_DEPTH, "Comment is nested ${x} posts deep, maximum depth is ${y}", ("x",parent->depth)("y",STEEMIT_MAX_COMMENT_DEPTH) ); + FC_ASSERT( parent->depth < STEEMIT_MAX_COMMENT_DEPTH, "Comment is nested ${x} posts deep, maximum depth is ${y}.", ("x",parent->depth)("y",STEEMIT_MAX_COMMENT_DEPTH) ); } auto now = db().head_block_time(); @@ -361,28 +361,28 @@ void comment_evaluator::do_apply( const comment_operation& o ) { if( o.parent_author != STEEMIT_ROOT_POST_PARENT ) { - FC_ASSERT( parent->root_comment( db() ).allow_replies, "Comment has disabled replies." ); + FC_ASSERT( parent->root_comment( db() ).allow_replies, "The parent comment has disabled replies." ); if( db().has_hardfork( STEEMIT_HARDFORK_0_12__177) ) - FC_ASSERT( db().calculate_discussion_payout_time( *parent ) != fc::time_point_sec::maximum(), "discussion is frozen" ); + FC_ASSERT( db().calculate_discussion_payout_time( *parent ) != fc::time_point_sec::maximum(), "Discussion is frozen." ); } if( db().has_hardfork( STEEMIT_HARDFORK_0_12__176 ) ) { if( o.parent_author == STEEMIT_ROOT_POST_PARENT ) - FC_ASSERT( (now - auth.last_root_post) > STEEMIT_MIN_ROOT_COMMENT_INTERVAL, "You may only post once every 5 minutes", ("now",now)("auth.last_root_post",auth.last_root_post) ); + FC_ASSERT( (now - auth.last_root_post) > STEEMIT_MIN_ROOT_COMMENT_INTERVAL, "You may only post once every 5 minutes.", ("now",now)("auth.last_root_post",auth.last_root_post) ); else - FC_ASSERT( (now - auth.last_post) > STEEMIT_MIN_REPLY_INTERVAL, "You may only comment once every 20 seconds", ("now",now)("auth.last_post",auth.last_post) ); + FC_ASSERT( (now - auth.last_post) > STEEMIT_MIN_REPLY_INTERVAL, "You may only comment once every 20 seconds.", ("now",now)("auth.last_post",auth.last_post) ); } else if( db().has_hardfork( STEEMIT_HARDFORK_0_6__113 ) ) { if( o.parent_author == STEEMIT_ROOT_POST_PARENT ) - FC_ASSERT( (now - auth.last_post) > STEEMIT_MIN_ROOT_COMMENT_INTERVAL, "You may only post once every 5 minutes", ("now",now)("auth.last_post",auth.last_post) ); + FC_ASSERT( (now - auth.last_post) > STEEMIT_MIN_ROOT_COMMENT_INTERVAL, "You may only post once every 5 minutes.", ("now",now)("auth.last_post",auth.last_post) ); else - FC_ASSERT( (now - auth.last_post) > STEEMIT_MIN_REPLY_INTERVAL, "You may only comment once every 20 seconds", ("now",now)("auth.last_post",auth.last_post) ); + FC_ASSERT( (now - auth.last_post) > STEEMIT_MIN_REPLY_INTERVAL, "You may only comment once every 20 seconds.", ("now",now)("auth.last_post",auth.last_post) ); } else { - FC_ASSERT( (now - auth.last_post) > fc::seconds(60), "You may only post once per minute", ("now",now)("auth.last_post",auth.last_post) ); + FC_ASSERT( (now - auth.last_post) > fc::seconds(60), "You may only post once per minute.", ("now",now)("auth.last_post",auth.last_post) ); } uint16_t reward_weight = STEEMIT_100_PERCENT; @@ -491,9 +491,9 @@ void comment_evaluator::do_apply( const comment_operation& o ) const auto& comment = *itr; if( db().has_hardfork( STEEMIT_HARDFORK_0_14__306 ) ) - FC_ASSERT( comment.mode != archived, "comment is archived" ); + FC_ASSERT( comment.mode != archived, "The comment is archived." ); else if( db().has_hardfork( STEEMIT_HARDFORK_0_10 ) ) - FC_ASSERT( comment.last_payout == fc::time_point_sec::min(), "Can only edit during the first 24 hours" ); + FC_ASSERT( comment.last_payout == fc::time_point_sec::min(), "Can only edit during the first 24 hours." ); db().modify( comment, [&]( comment_object& com ) { @@ -503,13 +503,13 @@ void comment_evaluator::do_apply( const comment_operation& o ) if( !parent ) { - FC_ASSERT( com.parent_author == account_name_type(), "The parent of a comment cannot change" ); - FC_ASSERT( equal( com.parent_permlink, o.parent_permlink ), "The permlink of a comment cannot change" ); + FC_ASSERT( com.parent_author == account_name_type(), "The parent of a comment cannot change." ); + FC_ASSERT( equal( com.parent_permlink, o.parent_permlink ), "The permlink of a comment cannot change." ); } else { - FC_ASSERT( com.parent_author == o.parent_author, "The parent of a comment cannot change" ); - FC_ASSERT( equal( com.parent_permlink, o.parent_permlink ), "The permlink of a comment cannot change" ); + FC_ASSERT( com.parent_author == o.parent_author, "The parent of a comment cannot change." ); + FC_ASSERT( equal( com.parent_permlink, o.parent_permlink ), "The permlink of a comment cannot change." ); } #ifndef IS_LOW_MEM @@ -547,14 +547,12 @@ void escrow_transfer_evaluator::do_apply( const escrow_transfer_operation& o ) { try { - FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_14__143 ), "op is not valid until next hardfork" ); /// TODO: remove this after HF14 - const auto& from_account = db().get_account(o.from); db().get_account(o.to); db().get_account(o.agent); - FC_ASSERT( o.ratification_deadline > db().head_block_time(), "ratification deadline must be after head block time" ); - FC_ASSERT( o.escrow_expiration > db().head_block_time(), "escrow expiration must be after head block time" ); + FC_ASSERT( o.ratification_deadline > db().head_block_time(), "The escorw ratification deadline must be after head block time." ); + FC_ASSERT( o.escrow_expiration > db().head_block_time(), "The escrow expiration must be after head block time." ); asset steem_spent = o.steem_amount; asset sbd_spent = o.sbd_amount; @@ -563,8 +561,8 @@ void escrow_transfer_evaluator::do_apply( const escrow_transfer_operation& o ) else sbd_spent += o.fee; - FC_ASSERT( from_account.balance >= steem_spent, "account cannot cover steem costs of escrow" ); - FC_ASSERT( from_account.sbd_balance >= sbd_spent, "account cannot cover sbd costs of escrow" ); + FC_ASSERT( from_account.balance >= steem_spent, "Account cannot cover STEEM costs of escrow. Required: ${r} Available: ${a}", ("r",steem_spent)("a",from_account.balance) ); + FC_ASSERT( from_account.sbd_balance >= sbd_spent, "Account cannot cover SBD costs of escrow. Required: ${r} Available: ${a}", ("r",sbd_spent)("a",from_account.sbd_balance) ); db().adjust_balance( from_account, -steem_spent ); db().adjust_balance( from_account, -sbd_spent ); @@ -589,19 +587,17 @@ void escrow_approve_evaluator::do_apply( const escrow_approve_operation& o ) { try { - FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_14__143 ), "op is not valid until next hardfork" ); /// TODO: remove this after HF14 - const auto& escrow = db().get_escrow( o.from, o.escrow_id ); - FC_ASSERT( escrow.to == o.to, "op 'to' does not match escrow 'to'" ); - FC_ASSERT( escrow.agent == o.agent, "op 'agent' does not match escrow 'agent'" ); - FC_ASSERT( escrow.ratification_deadline >= db().head_block_time(), "escrow ratification deadline is before head block time" ); + FC_ASSERT( escrow.to == o.to, "Operation 'to' (${o}) does not match escrow 'to' (${e}).", ("o", o.to)("e", escrow.to) ); + FC_ASSERT( escrow.agent == o.agent, "Operation 'agent' (${a}) does not match escrow 'agent' (${e}).", ("o", o.agent)("e", escrow.agent) ); + FC_ASSERT( escrow.ratification_deadline >= db().head_block_time(), "The escrow ratification deadline has passed. Escrow can no longer be ratified." ); bool reject_escrow = !o.approve; if( o.who == o.to ) { - FC_ASSERT( !escrow.to_approved, "'to' has already approved the escrow" ); + FC_ASSERT( !escrow.to_approved, "Account 'to' (${t}) has already approved the escrow.", ("t", o.to) ); if( !reject_escrow ) { @@ -613,7 +609,7 @@ void escrow_approve_evaluator::do_apply( const escrow_approve_operation& o ) } if( o.who == o.agent ) { - FC_ASSERT( !escrow.agent_approved, "'agent' has already approved the escrow" ); + FC_ASSERT( !escrow.agent_approved, "Account 'agent' (${a}) has already approved the escrow.", ("a", o.agent) ); if( !reject_escrow ) { @@ -651,15 +647,14 @@ void escrow_dispute_evaluator::do_apply( const escrow_dispute_operation& o ) { try { - FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_14__143 ), "op is not valid until next hardfork" ); /// TODO: remove this after HF14 db().get_account( o.from ); // Verify from account exists const auto& e = db().get_escrow( o.from, o.escrow_id ); - FC_ASSERT( db().head_block_time() < e.escrow_expiration, "disputes must be raised before expiration" ); - FC_ASSERT( e.to_approved && e.agent_approved, "escrow must be approved by all parties before a dispute can be raised" ); - FC_ASSERT( !e.disputed, "escrow is already under dispute" ); - FC_ASSERT( e.to == o.to, "op 'to' does not match escrow 'to'"); - FC_ASSERT( e.agent == o.agent, "op 'agent' does not match escrow 'agent'" ); + FC_ASSERT( db().head_block_time() < e.escrow_expiration, "Disputing the escrow must happen before expiration." ); + FC_ASSERT( e.to_approved && e.agent_approved, "The escrow must be approved by all parties before a dispute can be raised." ); + FC_ASSERT( !e.disputed, "The escrow is already under dispute." ); + FC_ASSERT( e.to == o.to, "Operation 'to' (${o}) does not match escrow 'to' (${e}).", ("o", o.to)("e", e.to) ); + FC_ASSERT( e.agent == o.agent, "Operation 'agent' (${a}) does not match escrow 'agent' (${e}).", ("o", o.agent)("e", e.agent) ); db().modify( e, [&]( escrow_object& esc ) { @@ -673,38 +668,36 @@ void escrow_release_evaluator::do_apply( const escrow_release_operation& o ) { try { - FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_14__143 ), "op is not valid until next hardfork" ); /// TODO: remove this after HF14 - db().get_account(o.from); // Verify from account exists const auto& receiver_account = db().get_account(o.receiver); const auto& e = db().get_escrow( o.from, o.escrow_id ); - FC_ASSERT( e.steem_balance >= o.steem_amount, "Release amount exceeds escrow balance" ); - FC_ASSERT( e.sbd_balance >= o.sbd_amount, "Release amount exceeds escrow balance" ); - FC_ASSERT( e.to == o.to, "op 'to' does not match escrow 'to'"); - FC_ASSERT( e.agent == o.agent, "op 'agent' does not match escrow 'agent'" ); - FC_ASSERT( o.receiver == e.from || o.receiver == e.to, "Funds must be released to 'from' or 'to'" ); - FC_ASSERT( e.to_approved && e.agent_approved, "Funds cannot be released prior to escrow approval" ); + FC_ASSERT( e.steem_balance >= o.steem_amount, "Release amount exceeds escrow balance. Amount: ${a}, Balance: ${b}", ("a", o.steem_amount)("b", e.steem_balance) ); + FC_ASSERT( e.sbd_balance >= o.sbd_amount, "Release amount exceeds escrow balance. Amount: ${a}, Balance: ${b}", ("a", o.sbd_amount)("b", e.sbd_balance) ); + FC_ASSERT( e.to == o.to, "Operation 'to' (${o}) does not match escrow 'to' (${e}).", ("o", o.to)("e", e.to) ); + FC_ASSERT( e.agent == o.agent, "Operation 'agent' (${a}) does not match escrow 'agent' (${e}).", ("o", o.agent)("e", e.agent) ); + FC_ASSERT( o.receiver == e.from || o.receiver == e.to, "Funds must be released to 'from' (${f}) or 'to' (${t})", ("f", e.from)("t", e.to) ); + FC_ASSERT( e.to_approved && e.agent_approved, "Funds cannot be released prior to escrow approval." ); // If there is a dispute regardless of expiration, the agent can release funds to either party if( e.disputed ) { - FC_ASSERT( o.who == e.agent, "'agent' must release funds for a disputed escrow" ); + FC_ASSERT( o.who == e.agent, "Only 'agent' (${a}) can release funds in a disputed escrow.", ("a", e.agent) ); } else { - FC_ASSERT( o.who == e.from || o.who == e.to, "Only 'from' and 'to' can release from a non-disputed escrow" ); + FC_ASSERT( o.who == e.from || o.who == e.to, "Only 'from' (${f}) and 'to' (${t}) can release funds from a non-disputed escrow", ("f", e.from)("t", e.to) ); if( e.escrow_expiration > db().head_block_time() ) { // If there is no dispute and escrow has not expired, either party can release funds to the other. if( o.who == e.from ) { - FC_ASSERT( o.receiver == e.to, "'from' must release funds to 'to'" ); + FC_ASSERT( o.receiver == e.to, "Only 'from' (${f}) can release funds to 'to' (${t}).", ("f", e.from)("t", e.to) ); } else if( o.who == e.to ) { - FC_ASSERT( o.receiver == e.from, "'to' must release funds to 'from'" ); + FC_ASSERT( o.receiver == e.from, "Only 'to' (${t}) can release funds to 'from' (${t}).", ("f", e.from)("t", e.to) ); } } } @@ -741,7 +734,7 @@ void transfer_evaluator::do_apply( const transfer_operation& o ) }); } - FC_ASSERT( db().get_balance( from_account, o.amount.symbol ) >= o.amount, "account does not have sufficient funds for transfer" ); + FC_ASSERT( db().get_balance( from_account, o.amount.symbol ) >= o.amount, "Account does not have sufficient funds for transfer." ); db().adjust_balance( from_account, -o.amount ); db().adjust_balance( to_account, o.amount ); } @@ -751,7 +744,7 @@ void transfer_to_vesting_evaluator::do_apply( const transfer_to_vesting_operatio const auto& from_account = db().get_account(o.from); const auto& to_account = o.to.size() ? db().get_account(o.to) : from_account; - FC_ASSERT( db().get_balance( from_account, STEEM_SYMBOL) >= o.amount, "account does not have sufficient STEEM for the transfer" ); + FC_ASSERT( db().get_balance( from_account, STEEM_SYMBOL) >= o.amount, "Account does not have sufficient STEEM for transfer." ); db().adjust_balance( from_account, -o.amount ); db().create_vesting( to_account, o.amount ); } @@ -760,8 +753,8 @@ void withdraw_vesting_evaluator::do_apply( const withdraw_vesting_operation& o ) { const auto& account = db().get_account( o.account ); - FC_ASSERT( account.vesting_shares >= asset( 0, VESTS_SYMBOL ), "account does not have sufficient Steem Power for withdraw" ); - FC_ASSERT( account.vesting_shares >= o.vesting_shares, "account does not have sufficient Steem Power for withdraw" ); + FC_ASSERT( account.vesting_shares >= asset( 0, VESTS_SYMBOL ), "Account does not have sufficient Steem Power for withdraw." ); + FC_ASSERT( account.vesting_shares >= o.vesting_shares, "Account does not have sufficient Steem Power for withdraw." ); if( !account.mined && db().has_hardfork( STEEMIT_HARDFORK_0_1 ) ) { @@ -772,13 +765,13 @@ void withdraw_vesting_evaluator::do_apply( const withdraw_vesting_operation& o ) min_vests.amount.value *= 10; FC_ASSERT( account.vesting_shares > min_vests, - "Account registered by another account requires 10x account creation fee worth of Steem Power before it can power down" ); + "Account registered by another account requires 10x account creation fee worth of Steem Power before it can be powered down." ); } if( o.vesting_shares.amount == 0 ) { if( db().is_producing() || db().has_hardfork( STEEMIT_HARDFORK_0_5__57 ) ) - FC_ASSERT( account.vesting_withdraw_rate.amount != 0, "this operation would not change the vesting withdraw rate" ); + FC_ASSERT( account.vesting_withdraw_rate.amount != 0, "This operation would not change the vesting withdraw rate." ); db().modify( account, [&]( account_object& a ) { a.vesting_withdraw_rate = asset( 0, VESTS_SYMBOL ); @@ -801,7 +794,7 @@ void withdraw_vesting_evaluator::do_apply( const withdraw_vesting_operation& o ) new_vesting_withdraw_rate.amount = 1; if( db().is_producing() || db().has_hardfork( STEEMIT_HARDFORK_0_5__57 ) ) - FC_ASSERT( account.vesting_withdraw_rate != new_vesting_withdraw_rate, "this operation would not change the vesting withdraw rate" ); + FC_ASSERT( account.vesting_withdraw_rate != new_vesting_withdraw_rate, "This operation would not change the vesting withdraw rate." ); a.vesting_withdraw_rate = new_vesting_withdraw_rate; a.next_vesting_withdrawal = db().head_block_time() + fc::seconds(STEEMIT_VESTING_WITHDRAW_INTERVAL_SECONDS); @@ -823,7 +816,7 @@ void set_withdraw_vesting_route_evaluator::do_apply( const set_withdraw_vesting_ if( itr == wd_idx.end() ) { FC_ASSERT( o.percent != 0, "Cannot create a 0% destination." ); - FC_ASSERT( from_account.withdraw_routes < STEEMIT_MAX_WITHDRAW_ROUTES, "account already has the maximum number of routes" ); + FC_ASSERT( from_account.withdraw_routes < STEEMIT_MAX_WITHDRAW_ROUTES, "Account already has the maximum number of routes." ); db().create< withdraw_vesting_route_object >( [&]( withdraw_vesting_route_object& wvdo ) { @@ -867,7 +860,7 @@ void set_withdraw_vesting_route_evaluator::do_apply( const set_withdraw_vesting_ ++itr; } - FC_ASSERT( total_percent <= STEEMIT_100_PERCENT, "More than 100% of vesting allocated to destinations" ); + FC_ASSERT( total_percent <= STEEMIT_100_PERCENT, "More than 100% of vesting withdrawals allocated to destinations." ); } FC_CAPTURE_AND_RETHROW() } @@ -875,9 +868,9 @@ void set_withdraw_vesting_route_evaluator::do_apply( const set_withdraw_vesting_ void account_witness_proxy_evaluator::do_apply( const account_witness_proxy_operation& o ) { const auto& account = db().get_account( o.account ); - FC_ASSERT( account.proxy != o.proxy, "something must change" ); + FC_ASSERT( account.proxy != o.proxy, "Proxy must change." ); - FC_ASSERT( account.can_vote, "Account has declined the ability to vote and cannot proxy votes" ); + FC_ASSERT( account.can_vote, "Account has declined the ability to vote and cannot proxy votes." ); /// remove all current votes std::array delta; @@ -895,9 +888,9 @@ void account_witness_proxy_evaluator::do_apply( const account_witness_proxy_oper auto cprox = &new_proxy; while( cprox->proxy.size() != 0 ) { const auto next_proxy = db().get_account( cprox->proxy ); - FC_ASSERT( proxy_chain.insert( next_proxy.id ).second, "Attempt to create a proxy loop" ); + FC_ASSERT( proxy_chain.insert( next_proxy.id ).second, "This proxy would create a proxy loop." ); cprox = &next_proxy; - FC_ASSERT( proxy_chain.size() <= STEEMIT_MAX_PROXY_RECURSION_DEPTH, "Proxy chain is too long" ); + FC_ASSERT( proxy_chain.size() <= STEEMIT_MAX_PROXY_RECURSION_DEPTH, "Proxy chain is too long." ); } /// clear all individual vote records @@ -922,10 +915,10 @@ void account_witness_proxy_evaluator::do_apply( const account_witness_proxy_oper void account_witness_vote_evaluator::do_apply( const account_witness_vote_operation& o ) { const auto& voter = db().get_account( o.account ); - FC_ASSERT( voter.proxy.size() == 0, "A proxy is currently set, please clear the proxy before voting for a witness" ); + FC_ASSERT( voter.proxy.size() == 0, "A proxy is currently set, please clear the proxy before voting for a witness." ); if( o.approve ) - FC_ASSERT( voter.can_vote, "Account has declined its voting rights" ); + FC_ASSERT( voter.can_vote, "Account has declined its voting rights." ); const auto& witness = db().get_witness( o.witness ); @@ -933,11 +926,11 @@ void account_witness_vote_evaluator::do_apply( const account_witness_vote_operat auto itr = by_account_witness_idx.find( boost::make_tuple( voter.id, witness.id ) ); if( itr == by_account_witness_idx.end() ) { - FC_ASSERT( o.approve, "vote doesn't exist, user must be indicate a desire to approve witness" ); + FC_ASSERT( o.approve, "Vote doesn't exist, user must indicate a desire to approve witness." ); if ( db().has_hardfork( STEEMIT_HARDFORK_0_2 ) ) { - FC_ASSERT( voter.witnesses_voted_for < STEEMIT_MAX_ACCOUNT_WITNESS_VOTES, "account has voted for too many witnesses" ); // TODO: Remove after hardfork 2 + FC_ASSERT( voter.witnesses_voted_for < STEEMIT_MAX_ACCOUNT_WITNESS_VOTES, "Account has voted for too many witnesses." ); // TODO: Remove after hardfork 2 db().create( [&]( witness_vote_object& v ) { v.witness = witness.id; @@ -967,7 +960,7 @@ void account_witness_vote_evaluator::do_apply( const account_witness_vote_operat }); } else { - FC_ASSERT( !o.approve, "vote currently exists, user must be indicate a desire to reject witness" ); + FC_ASSERT( !o.approve, "Vote currently exists, user must indicate a desire to reject witness." ); if ( db().has_hardfork( STEEMIT_HARDFORK_0_2 ) ) { if( db().has_hardfork( STEEMIT_HARDFORK_0_3 ) ) @@ -993,11 +986,11 @@ void vote_evaluator::do_apply( const vote_operation& o ) const auto& voter = db().get_account( o.voter ); if( db().has_hardfork( STEEMIT_HARDFORK_0_10 ) ) - FC_ASSERT( !(voter.owner_challenged || voter.active_challenged ), "Account is currently challenged" ); + FC_ASSERT( !(voter.owner_challenged || voter.active_challenged ), "Operation cannot be processed because the account is currently challenged." ); - FC_ASSERT( voter.can_vote, "Voter has declined their voting rights" ); + FC_ASSERT( voter.can_vote, "Voter has declined their voting rights." ); - if( o.weight > 0 ) FC_ASSERT( comment.allow_votes, "Votes are not allowed on the comment" ); + if( o.weight > 0 ) FC_ASSERT( comment.allow_votes, "Votes are not allowed on the comment." ); if( db().has_hardfork( STEEMIT_HARDFORK_0_12__177 ) && db().calculate_discussion_payout_time( comment ) == fc::time_point_sec::maximum() ) { @@ -1029,11 +1022,11 @@ void vote_evaluator::do_apply( const vote_operation& o ) int64_t elapsed_seconds = (db().head_block_time() - voter.last_vote_time).to_seconds(); if( db().has_hardfork( STEEMIT_HARDFORK_0_11 ) ) - FC_ASSERT( elapsed_seconds >= STEEMIT_MIN_VOTE_INTERVAL_SEC, "Can only vote once every 3 seconds" ); + FC_ASSERT( elapsed_seconds >= STEEMIT_MIN_VOTE_INTERVAL_SEC, "Can only vote once every 3 seconds." ); int64_t regenerated_power = (STEEMIT_100_PERCENT * elapsed_seconds) / STEEMIT_VOTE_REGENERATION_SECONDS; int64_t current_power = std::min( int64_t(voter.voting_power + regenerated_power), int64_t(STEEMIT_100_PERCENT) ); - FC_ASSERT( current_power > 0, "Account currently does not have voting power" ); + FC_ASSERT( current_power > 0, "Account currently does not have voting power." ); int64_t abs_weight = abs(o.weight); int64_t used_power = (current_power * abs_weight) / STEEMIT_100_PERCENT; @@ -1054,18 +1047,18 @@ void vote_evaluator::do_apply( const vote_operation& o ) { used_power = (used_power + max_vote_denom - 1) / max_vote_denom; } - FC_ASSERT( used_power <= current_power, "Account does not have enough power for vote" ); + FC_ASSERT( used_power <= current_power, "Account does not have enough power to vote." ); int64_t abs_rshares = ((uint128_t(voter.vesting_shares.amount.value) * used_power) / (STEEMIT_100_PERCENT)).to_uint64(); if( !db().has_hardfork( STEEMIT_HARDFORK_0_14__259 ) && abs_rshares == 0 ) abs_rshares = 1; if( db().has_hardfork( STEEMIT_HARDFORK_0_14__259 ) ) { - FC_ASSERT( abs_rshares > 50000000 || o.weight == 0, "voting weight is too small, please accumulate more voting power or steem power" ); + FC_ASSERT( abs_rshares > 50000000 || o.weight == 0, "Voting weight is too small, please accumulate more voting power or steem power." ); } else if( db().has_hardfork( STEEMIT_HARDFORK_0_13__248 ) ) { - FC_ASSERT( abs_rshares > 50000000 || abs_rshares == 1, "voting weight is too small, please accumulate more voting power or steem power" ); + FC_ASSERT( abs_rshares > 50000000 || abs_rshares == 1, "Voting weight is too small, please accumulate more voting power or steem power." ); } @@ -1074,7 +1067,7 @@ void vote_evaluator::do_apply( const vote_operation& o ) if( itr != comment_vote_idx.end() && itr->num_changes == -1 ) { if( db().is_producing() || db().has_hardfork( STEEMIT_HARDFORK_0_12__177 ) ) - FC_ASSERT( false, "Cannot vote again on a comment after payout" ); + FC_ASSERT( false, "Cannot vote again on a comment after payout." ); db().remove( *itr ); itr = comment_vote_idx.end(); @@ -1082,13 +1075,13 @@ void vote_evaluator::do_apply( const vote_operation& o ) if( itr == comment_vote_idx.end() ) { - FC_ASSERT( o.weight != 0, "Vote weight cannot be 0" ); + FC_ASSERT( o.weight != 0, "Vote weight cannot be 0." ); /// this is the rshares voting for or against the post int64_t rshares = o.weight < 0 ? -abs_rshares : abs_rshares; if( rshares > 0 && db().has_hardfork( STEEMIT_HARDFORK_0_7 ) ) { - FC_ASSERT( db().head_block_time() < db().calculate_discussion_payout_time( comment ) - STEEMIT_UPVOTE_LOCKOUT, "Cannot increase reward of post within the last minute before payout" ); + FC_ASSERT( db().head_block_time() < db().calculate_discussion_payout_time( comment ) - STEEMIT_UPVOTE_LOCKOUT, "Cannot increase reward of post within the last minute before payout." ); } //used_power /= (50*7); /// a 100% vote means use .28% of voting power which should force users to spread their votes around over 50+ posts day for a week @@ -1114,7 +1107,7 @@ void vote_evaluator::do_apply( const vote_operation& o ) auto avg_cashout_sec = ( cur_cashout_time_sec * old_root_abs_rshares + new_cashout_time_sec * abs_rshares ) / ( old_root_abs_rshares + abs_rshares ); - FC_ASSERT( abs_rshares > 0, "Cannot vote with no rshares" ); + FC_ASSERT( abs_rshares > 0, "Cannot vote with 0 rshares." ); auto old_vote_rshares = comment.vote_rshares; @@ -1243,16 +1236,16 @@ void vote_evaluator::do_apply( const vote_operation& o ) } else { - FC_ASSERT( itr->num_changes < STEEMIT_MAX_VOTE_CHANGES, "Cannot change vote again" ); + FC_ASSERT( itr->num_changes < STEEMIT_MAX_VOTE_CHANGES, "Voter has used the maximum number of vote changes on this comment." ); if( db().is_producing() || db().has_hardfork( STEEMIT_HARDFORK_0_6__112 ) ) - FC_ASSERT( itr->vote_percent != o.weight, "Changing your vote requires actually changing you vote." ); + FC_ASSERT( itr->vote_percent != o.weight, "You have already voted in a similar way." ); /// this is the rshares voting for or against the post int64_t rshares = o.weight < 0 ? -abs_rshares : abs_rshares; if( itr->rshares < rshares && db().has_hardfork( STEEMIT_HARDFORK_0_7 ) ) - FC_ASSERT( db().head_block_time() < db().calculate_discussion_payout_time( comment ) - STEEMIT_UPVOTE_LOCKOUT, "Cannot increase payout withing last minute before payout" ); + FC_ASSERT( db().head_block_time() < db().calculate_discussion_payout_time( comment ) - STEEMIT_UPVOTE_LOCKOUT, "Cannot increase payout within last minute before payout." ); db().modify( voter, [&]( account_object& a ){ a.voting_power = current_power - used_power; @@ -1356,7 +1349,7 @@ void custom_json_evaluator::do_apply( const custom_json_operation& o ) } catch(...) { - elog( "unexpected exception applying custom json evaluator" ); + elog( "Unexpected exception applying custom json evaluator." ); } } @@ -1381,7 +1374,7 @@ void custom_binary_evaluator::do_apply( const custom_binary_operation& o ) } catch(...) { - elog( "unexpected exception applying custom json evaluator" ); + elog( "Unexpected exception applying custom json evaluator." ); } } @@ -1430,16 +1423,16 @@ void pow_apply( database& db, Operation o ) const auto& worker_account = db.get_account( o.get_worker_account() ); // verify it exists const auto& worker_auth = db.get< account_authority_object, by_account >( o.get_worker_account() ); - FC_ASSERT( worker_auth.active.num_auths() == 1, "miners can only have one key auth ${a}", ("a",worker_auth.active) ); - FC_ASSERT( worker_auth.active.key_auths.size() == 1, "miners may only have one key auth" ); - FC_ASSERT( worker_auth.active.key_auths.begin()->first == o.work.worker, "work must be performed by key that signed the work" ); + FC_ASSERT( worker_auth.active.num_auths() == 1, "Miners can only have one key authority. ${a}", ("a",worker_auth.active) ); + FC_ASSERT( worker_auth.active.key_auths.size() == 1, "Miners may only have one key authority." ); + FC_ASSERT( worker_auth.active.key_auths.begin()->first == o.work.worker, "Work must be performed by key that signed the work." ); FC_ASSERT( o.block_id == db.head_block_id(), "pow not for last block" ); if( db.has_hardfork( STEEMIT_HARDFORK_0_13__256 ) ) - FC_ASSERT( worker_account.last_account_update < db.head_block_time(), "worker account must not have updated their account this block" ); + FC_ASSERT( worker_account.last_account_update < db.head_block_time(), "Worker account must not have updated their account this block." ); fc::sha256 target = db.get_pow_target(); - FC_ASSERT( o.work.work < target, "work lacks sufficient difficulty" ); + FC_ASSERT( o.work.work < target, "Work lacks sufficient difficulty." ); db.modify( dgp, [&]( dynamic_global_property_object& p ) { @@ -1450,7 +1443,7 @@ void pow_apply( database& db, Operation o ) const witness_object* cur_witness = db.find_witness( worker_account.name ); if( cur_witness ) { - FC_ASSERT( cur_witness->pow_worker == 0, "this account is already scheduled for pow block production" ); + FC_ASSERT( cur_witness->pow_worker == 0, "This account is already scheduled for pow block production." ); db.modify(*cur_witness, [&]( witness_object& w ){ w.props = o.props; w.pow_worker = dgp.total_pow; @@ -1496,22 +1489,22 @@ void pow2_evaluator::do_apply( const pow2_operation& o ) if( db.has_hardfork( STEEMIT_HARDFORK_0_16__551 ) ) { const auto& work = o.work.get< equihash_pow >(); - FC_ASSERT( work.prev_block == db.head_block_id(), "equihash pow op not for last block" ); + FC_ASSERT( work.prev_block == db.head_block_id(), "Equihash pow op not for last block" ); auto recent_block_num = db.get< block_stats_object, by_block_id >( work.input.prev_block ).block_num(); FC_ASSERT( recent_block_num > dgp.last_irreversible_block_num, "Equihash pow done for block older than last irreversible block num" ); - FC_ASSERT( work.pow_summary < target_pow, "insufficient work difficulty", ("pow", work.pow_summary)("target", target_pow) ); + FC_ASSERT( work.pow_summary < target_pow, "Insufficient work difficulty. Work: ${w}, Target: ${t}", ("w",work.pow_summary)("t", target_pow) ); worker_account = work.input.worker_account; } else { const auto& work = o.work.get< pow2 >(); - FC_ASSERT( work.input.prev_block == db.head_block_id(), "pow not for last block" ); - FC_ASSERT( work.pow_summary < target_pow, "insufficient work difficulty", ("pow", work.pow_summary)("target", target_pow) ); + FC_ASSERT( work.input.prev_block == db.head_block_id(), "Work not for last block" ); + FC_ASSERT( work.pow_summary < target_pow, "Insufficient work difficulty. Work: ${w}, Target: ${t}", ("w",work.pow_summary)("t", target_pow) ); worker_account = work.input.worker_account; } - FC_ASSERT( o.props.maximum_block_size >= STEEMIT_MIN_BLOCK_SIZE_LIMIT * 2, "maximum block size is too small" ); + FC_ASSERT( o.props.maximum_block_size >= STEEMIT_MIN_BLOCK_SIZE_LIMIT * 2, "Voted maximum block size is too small." ); db.modify( dgp, [&]( dynamic_global_property_object& p ) { @@ -1523,7 +1516,7 @@ void pow2_evaluator::do_apply( const pow2_operation& o ) auto itr = accounts_by_name.find( worker_account ); if(itr == accounts_by_name.end()) { - FC_ASSERT( o.new_owner_key.valid(), "new owner key is not valid" ); + FC_ASSERT( o.new_owner_key.valid(), "New owner key is not valid." ); db.create< account_object >( [&]( account_object& acc ) { acc.name = worker_account; @@ -1551,10 +1544,10 @@ void pow2_evaluator::do_apply( const pow2_operation& o ) } else { - FC_ASSERT( !o.new_owner_key.valid(), "cannot specify an owner key unless creating account" ); + FC_ASSERT( !o.new_owner_key.valid(), "Cannot specify an owner key unless creating account." ); const witness_object* cur_witness = db.find_witness( worker_account ); - FC_ASSERT( cur_witness, "Witness must be created for existing account before mining" ); - FC_ASSERT( cur_witness->pow_worker == 0, "this account is already scheduled for pow block production" ); + FC_ASSERT( cur_witness, "Witness must be created for existing account before mining."); + FC_ASSERT( cur_witness->pow_worker == 0, "This account is already scheduled for pow block production." ); db.modify(*cur_witness, [&]( witness_object& w ) { w.props = o.props; @@ -1585,12 +1578,12 @@ void feed_publish_evaluator::do_apply( const feed_publish_operation& o ) void convert_evaluator::do_apply( const convert_operation& o ) { const auto& owner = db().get_account( o.owner ); - FC_ASSERT( db().get_balance( owner, o.amount.symbol ) >= o.amount, "account does not sufficient balance" ); + FC_ASSERT( db().get_balance( owner, o.amount.symbol ) >= o.amount, "Account does not have sufficient balance for conversion." ); db().adjust_balance( owner, -o.amount ); const auto& fhistory = db().get_feed_history(); - FC_ASSERT( !fhistory.current_median_history.is_null(), "Cannot convert SBD because there is no price feed" ); + FC_ASSERT( !fhistory.current_median_history.is_null(), "Cannot convert SBD because there is no price feed." ); auto steemit_conversion_delay = STEEMIT_CONVERSION_DELAY_PRE_HF_16; if( db().has_hardfork( STEEMIT_HARDFORK_0_16__551) ) @@ -1608,11 +1601,11 @@ void convert_evaluator::do_apply( const convert_operation& o ) void limit_order_create_evaluator::do_apply( const limit_order_create_operation& o ) { - FC_ASSERT( o.expiration > db().head_block_time(), "limit order has to expire after head block time" ); + FC_ASSERT( o.expiration > db().head_block_time(), "Limit order has to expire after head block time." ); const auto& owner = db().get_account( o.owner ); - FC_ASSERT( db().get_balance( owner, o.amount_to_sell.symbol ) >= o.amount_to_sell, "account does not have sufficient funds for limit order" ); + FC_ASSERT( db().get_balance( owner, o.amount_to_sell.symbol ) >= o.amount_to_sell, "Account does not have sufficient funds for limit order." ); db().adjust_balance( owner, -o.amount_to_sell ); @@ -1628,16 +1621,16 @@ void limit_order_create_evaluator::do_apply( const limit_order_create_operation& bool filled = db().apply_order( order ); - if( o.fill_or_kill ) FC_ASSERT( filled, "cancelling order because it was not filled" ); + if( o.fill_or_kill ) FC_ASSERT( filled, "Cancelling order because it was not filled." ); } void limit_order_create2_evaluator::do_apply( const limit_order_create2_operation& o ) { - FC_ASSERT( o.expiration > db().head_block_time(), "limit order has to expire after head block time" ); + FC_ASSERT( o.expiration > db().head_block_time(), "Limit order has to expire after head block time." ); const auto& owner = db().get_account( o.owner ); - FC_ASSERT( db().get_balance( owner, o.amount_to_sell.symbol ) >= o.amount_to_sell, "account does not have sufficient funds for limit order" ); + FC_ASSERT( db().get_balance( owner, o.amount_to_sell.symbol ) >= o.amount_to_sell, "Account does not have sufficient funds for limit order." ); db().adjust_balance( owner, -o.amount_to_sell ); @@ -1653,7 +1646,7 @@ void limit_order_create2_evaluator::do_apply( const limit_order_create2_operatio bool filled = db().apply_order( order ); - if( o.fill_or_kill ) FC_ASSERT( filled, "cancelling order because it was not filled" ); + if( o.fill_or_kill ) FC_ASSERT( filled, "Cancelling order because it was not filled." ); } void limit_order_cancel_evaluator::do_apply( const limit_order_cancel_operation& o ) @@ -1663,18 +1656,18 @@ void limit_order_cancel_evaluator::do_apply( const limit_order_cancel_operation& void report_over_production_evaluator::do_apply( const report_over_production_operation& o ) { - FC_ASSERT( !db().has_hardfork( STEEMIT_HARDFORK_0_4 ), "this operation is disabled" ); + FC_ASSERT( !db().has_hardfork( STEEMIT_HARDFORK_0_4 ), "report_over_production_operation is disabled." ); } void challenge_authority_evaluator::do_apply( const challenge_authority_operation& o ) { - if( db().has_hardfork( STEEMIT_HARDFORK_0_14__307 ) ) FC_ASSERT( false, "Challenge authority operation is currently disabled" ); + if( db().has_hardfork( STEEMIT_HARDFORK_0_14__307 ) ) FC_ASSERT( false, "Challenge authority operation is currently disabled." ); const auto& challenged = db().get_account( o.challenged ); const auto& challenger = db().get_account( o.challenger ); if( o.require_owner ) { - FC_ASSERT( challenged.reset_account == o.challenger, "Owner authority can only be challenged by the reset account" ); + FC_ASSERT( challenged.reset_account == o.challenger, "Owner authority can only be challenged by its reset account." ); FC_ASSERT( challenger.balance >= STEEMIT_OWNER_CHALLENGE_FEE ); FC_ASSERT( !challenged.owner_challenged ); FC_ASSERT( db().head_block_time() - challenged.last_owner_proved > STEEMIT_OWNER_CHALLENGE_COOLDOWN ); @@ -1689,9 +1682,9 @@ void challenge_authority_evaluator::do_apply( const challenge_authority_operatio } else { - FC_ASSERT( challenger.balance >= STEEMIT_ACTIVE_CHALLENGE_FEE, "account does not have sufficient funds to pay challenge fee" ); - FC_ASSERT( !( challenged.owner_challenged || challenged.active_challenged ), "account is already challenged" ); - FC_ASSERT( db().head_block_time() - challenged.last_active_proved > STEEMIT_ACTIVE_CHALLENGE_COOLDOWN, "account cannot be challenged because it was recently challenged" ); + FC_ASSERT( challenger.balance >= STEEMIT_ACTIVE_CHALLENGE_FEE, "Account does not have sufficient funds to pay challenge fee." ); + FC_ASSERT( !( challenged.owner_challenged || challenged.active_challenged ), "Account is already challenged." ); + FC_ASSERT( db().head_block_time() - challenged.last_active_proved > STEEMIT_ACTIVE_CHALLENGE_COOLDOWN, "Account cannot be challenged because it was recently challenged." ); db().adjust_balance( challenger, - STEEMIT_ACTIVE_CHALLENGE_FEE ); db().create_vesting( db().get_account( o.challenged ), STEEMIT_ACTIVE_CHALLENGE_FEE ); @@ -1725,17 +1718,17 @@ void request_account_recovery_evaluator::do_apply( const request_account_recover const auto& account_to_recover = db().get_account( o.account_to_recover ); if ( account_to_recover.recovery_account.length() ) // Make sure recovery matches expected recovery account - FC_ASSERT( account_to_recover.recovery_account == o.recovery_account, "cannot recover an account that does not have you as there recovery partner" ); + FC_ASSERT( account_to_recover.recovery_account == o.recovery_account, "Cannot recover an account that does not have you as there recovery partner." ); else // Empty string recovery account defaults to top witness - FC_ASSERT( db().get_index< witness_index >().indices().get< by_vote_name >().begin()->owner == o.recovery_account, "top witness must recover an account with no recovery partner" ); + FC_ASSERT( db().get_index< witness_index >().indices().get< by_vote_name >().begin()->owner == o.recovery_account, "Top witness must recover an account with no recovery partner." ); const auto& recovery_request_idx = db().get_index< account_recovery_request_index >().indices().get< by_account >(); auto request = recovery_request_idx.find( o.account_to_recover ); if( request == recovery_request_idx.end() ) // New Request { - FC_ASSERT( !o.new_owner_authority.is_impossible(), "Cannot recover with an impossible authority" ); - FC_ASSERT( o.new_owner_authority.weight_threshold, "Cannot recover with an open authority" ); + FC_ASSERT( !o.new_owner_authority.is_impossible(), "Cannot recover using an impossible authority." ); + FC_ASSERT( o.new_owner_authority.weight_threshold, "Cannot recover using an open authority." ); // Check accounts in the new authority exist if( ( db().has_hardfork( STEEMIT_HARDFORK_0_15__465 ) || db().is_producing() ) ) @@ -1759,7 +1752,7 @@ void request_account_recovery_evaluator::do_apply( const request_account_recover } else // Change Request { - FC_ASSERT( !o.new_owner_authority.is_impossible(), "Cannot recover with an impossible authority" ); + FC_ASSERT( !o.new_owner_authority.is_impossible(), "Cannot recover using an impossible authority." ); // Check accounts in the new authority exist if( ( db().has_hardfork( STEEMIT_HARDFORK_0_15__465 ) || db().is_producing() ) ) @@ -1783,13 +1776,13 @@ void recover_account_evaluator::do_apply( const recover_account_operation& o ) const auto& account = db().get_account( o.account_to_recover ); if( db().has_hardfork( STEEMIT_HARDFORK_0_12 ) ) - FC_ASSERT( db().head_block_time() - account.last_account_recovery > STEEMIT_OWNER_UPDATE_LIMIT, "owner authority can only be updated once an hour" ); + FC_ASSERT( db().head_block_time() - account.last_account_recovery > STEEMIT_OWNER_UPDATE_LIMIT, "Owner authority can only be updated once an hour." ); const auto& recovery_request_idx = db().get_index< account_recovery_request_index >().indices().get< by_account >(); auto request = recovery_request_idx.find( o.account_to_recover ); - FC_ASSERT( request != recovery_request_idx.end(), "there are no active recovery requests for this account" ); - FC_ASSERT( request->new_owner_authority == o.new_owner_authority, "new owner authority does not match recovery request" ); + FC_ASSERT( request != recovery_request_idx.end(), "There are no active recovery requests for this account." ); + FC_ASSERT( request->new_owner_authority == o.new_owner_authority, "New owner authority does not match recovery request." ); const auto& recent_auth_idx = db().get_index< owner_authority_history_index >().indices().get< by_account >(); auto hist = recent_auth_idx.lower_bound( o.account_to_recover ); @@ -1802,7 +1795,7 @@ void recover_account_evaluator::do_apply( const recover_account_operation& o ) ++hist; } - FC_ASSERT( found, "Recent authority not found in authority history" ); + FC_ASSERT( found, "Recent authority not found in authority history." ); db().remove( *request ); // Remove first, update_owner_authority may invalidate iterator db().update_owner_authority( account, o.new_owner_authority ); @@ -1845,10 +1838,9 @@ void change_recovery_account_evaluator::do_apply( const change_recovery_account_ void transfer_to_savings_evaluator::do_apply( const transfer_to_savings_operation& op ) { - FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_14__239 ), "operation not active until next hardfork" ); // TODO: Remove after hf14 const auto& from = db().get_account( op.from ); const auto& to = db().get_account(op.to); - FC_ASSERT( db().get_balance( from, op.amount.symbol ) >= op.amount, "Account does not have sufficient funds for transfer." ); + FC_ASSERT( db().get_balance( from, op.amount.symbol ) >= op.amount, "Account does not have sufficient funds to transfer to savings." ); db().adjust_balance( from, -op.amount ); db().adjust_savings_balance( to, op.amount ); @@ -1856,7 +1848,6 @@ void transfer_to_savings_evaluator::do_apply( const transfer_to_savings_operatio void transfer_from_savings_evaluator::do_apply( const transfer_from_savings_operation& op ) { - FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_14__239 ), "operation not active until next hardfork" ); // TODO: Remove after hf14 const auto& from = db().get_account( op.from ); db().get_account(op.to); // Verify to account exists @@ -1883,8 +1874,6 @@ void transfer_from_savings_evaluator::do_apply( const transfer_from_savings_oper void cancel_transfer_from_savings_evaluator::do_apply( const cancel_transfer_from_savings_operation& op ) { - FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_14__239 ), "operation not active until next hardfork" ); // TODO: Remove after hf14 - const auto& swo = db().get_savings_withdraw( op.from, op.request_id ); db().adjust_savings_balance( db().get_account( swo.from ), swo.amount ); db().remove( swo ); @@ -1906,7 +1895,7 @@ void decline_voting_rights_evaluator::do_apply( const decline_voting_rights_oper if( o.decline ) { - FC_ASSERT( itr == request_idx.end(), "Cannot create new request because one already exists" ); + FC_ASSERT( itr == request_idx.end(), "Cannot create new request because one already exists." ); db().create< decline_voting_rights_request_object >( [&]( decline_voting_rights_request_object& req ) { @@ -1916,7 +1905,7 @@ void decline_voting_rights_evaluator::do_apply( const decline_voting_rights_oper } else { - FC_ASSERT( itr != request_idx.end(), "Cannot cancel the request because it does not exist" ); + FC_ASSERT( itr != request_idx.end(), "Cannot cancel the request because it does not exist." ); db().remove( *itr ); } } diff --git a/libraries/plugins/tags/include/steemit/tags/tags_plugin.hpp b/libraries/plugins/tags/include/steemit/tags/tags_plugin.hpp index b80601d671..5824d1ceaf 100644 --- a/libraries/plugins/tags/include/steemit/tags/tags_plugin.hpp +++ b/libraries/plugins/tags/include/steemit/tags/tags_plugin.hpp @@ -279,26 +279,28 @@ typedef multi_index_container< indexed_by< ordered_unique< tag< by_id >, member< tag_stats_object, tag_stats_id_type, &tag_stats_object::id > >, ordered_unique< tag< by_tag >, member< tag_stats_object, tag_name_type, &tag_stats_object::tag > >, + /* ordered_non_unique< tag< by_comments >, composite_key< tag_stats_object, - member< tag_stats_object, tag_name_type, &tag_stats_object::tag >, - member< tag_stats_object, uint32_t, &tag_stats_object::comments > + member< tag_stats_object, uint32_t, &tag_stats_object::comments >, + member< tag_stats_object, tag_name_type, &tag_stats_object::tag > >, composite_key_compare< std::less< tag_name_type >, std::greater< uint32_t > > >, ordered_non_unique< tag< by_top_posts >, composite_key< tag_stats_object, - member< tag_stats_object, tag_name_type, &tag_stats_object::tag >, - member< tag_stats_object, uint32_t, &tag_stats_object::top_posts > + member< tag_stats_object, uint32_t, &tag_stats_object::top_posts >, + member< tag_stats_object, tag_name_type, &tag_stats_object::tag > >, composite_key_compare< std::less< tag_name_type >, std::greater< uint32_t > > >, + */ ordered_non_unique< tag< by_trending >, composite_key< tag_stats_object, - member< tag_stats_object, tag_name_type, &tag_stats_object::tag >, - member< tag_stats_object, fc::uint128_t, &tag_stats_object::total_children_rshares2 > + member< tag_stats_object, fc::uint128_t, &tag_stats_object::total_children_rshares2 >, + member< tag_stats_object, tag_name_type, &tag_stats_object::tag > >, - composite_key_compare< std::less< tag_name_type >, std::greater< uint128_t > > + composite_key_compare< std::greater< uint128_t >, std::less< tag_name_type > > > >, allocator< tag_stats_object > diff --git a/libraries/plugins/tags/tags_plugin.cpp b/libraries/plugins/tags/tags_plugin.cpp index db2db2e4ee..557e1e6a2a 100644 --- a/libraries/plugins/tags/tags_plugin.cpp +++ b/libraries/plugins/tags/tags_plugin.cpp @@ -356,6 +356,11 @@ struct operation_visitor { update_tags( c ); } + void operator()( const comment_payout_update_operation& op )const { + const auto& c = _db.get_comment( op.author, op.permlink ); + update_tags( c ); + } + template void operator()( Op&& )const{} /// ignore all other ops }; diff --git a/libraries/protocol/include/steemit/protocol/operations.hpp b/libraries/protocol/include/steemit/protocol/operations.hpp index e040e067ee..08e4751176 100644 --- a/libraries/protocol/include/steemit/protocol/operations.hpp +++ b/libraries/protocol/include/steemit/protocol/operations.hpp @@ -70,7 +70,8 @@ namespace steemit { namespace protocol { fill_order_operation, shutdown_witness_operation, fill_transfer_from_savings_operation, - hardfork_operation + hardfork_operation, + comment_payout_update_operation > operation; /*void operation_get_required_authorities( const operation& op, diff --git a/libraries/protocol/include/steemit/protocol/steem_virtual_operations.hpp b/libraries/protocol/include/steemit/protocol/steem_virtual_operations.hpp index c86c8a0c34..7f0317bbf2 100644 --- a/libraries/protocol/include/steemit/protocol/steem_virtual_operations.hpp +++ b/libraries/protocol/include/steemit/protocol/steem_virtual_operations.hpp @@ -136,6 +136,15 @@ namespace steemit { namespace protocol { uint32_t hardfork_id = 0; }; + struct comment_payout_update_operation : public virtual_operation + { + comment_payout_update_operation() {} + comment_payout_update_operation( const account_name_type& a, const string& p ) : author( a ), permlink( p ) {} + + account_name_type author; + string permlink; + }; + } } //steemit::protocol FC_REFLECT( steemit::protocol::author_reward_operation, (author)(permlink)(sbd_payout)(steem_payout)(vesting_payout) ) @@ -149,3 +158,4 @@ FC_REFLECT( steemit::protocol::shutdown_witness_operation, (owner) ) FC_REFLECT( steemit::protocol::fill_order_operation, (current_owner)(current_orderid)(current_pays)(open_owner)(open_orderid)(open_pays) ) FC_REFLECT( steemit::protocol::fill_transfer_from_savings_operation, (from)(to)(amount)(request_id)(memo) ) FC_REFLECT( steemit::protocol::hardfork_operation, (hardfork_id) ) +FC_REFLECT( steemit::protocol::comment_payout_update_operation, (author)(permlink) ) diff --git a/libraries/wallet/CMakeLists.txt b/libraries/wallet/CMakeLists.txt index 519445e53e..cafd74b943 100644 --- a/libraries/wallet/CMakeLists.txt +++ b/libraries/wallet/CMakeLists.txt @@ -26,7 +26,7 @@ endif() add_library( steemit_wallet wallet.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp ${HEADERS} ) # I don't know why steemit_app is required twice in the following line, I just know the linker breaks if it isn't. target_link_libraries( steemit_wallet PRIVATE steemit_app graphene_net steemit_chain steemit_protocol graphene_utilities fc steemit_private_message steemit_app steemit_follow steemit_account_by_key ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) -target_include_directories( steemit_wallet PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include" ) +target_include_directories( steemit_wallet PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) if(MSVC) set_source_files_properties( wallet.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) diff --git a/tests/tests/basic_tests.cpp b/tests/tests/basic_tests.cpp index e1315bca4d..1c9468f5fb 100644 --- a/tests/tests/basic_tests.cpp +++ b/tests/tests/basic_tests.cpp @@ -42,6 +42,30 @@ using namespace steemit::protocol; BOOST_FIXTURE_TEST_SUITE( basic_tests, clean_database_fixture ) +BOOST_AUTO_TEST_CASE( parse_size_test ) +{ + BOOST_CHECK_THROW( fc::parse_size( "" ), fc::parse_error_exception ); + BOOST_CHECK_THROW( fc::parse_size( "k" ), fc::parse_error_exception ); + + BOOST_CHECK_EQUAL( fc::parse_size( "0" ), 0 ); + BOOST_CHECK_EQUAL( fc::parse_size( "1" ), 1 ); + BOOST_CHECK_EQUAL( fc::parse_size( "2" ), 2 ); + BOOST_CHECK_EQUAL( fc::parse_size( "3" ), 3 ); + BOOST_CHECK_EQUAL( fc::parse_size( "4" ), 4 ); + + BOOST_CHECK_EQUAL( fc::parse_size( "9" ), 9 ); + BOOST_CHECK_EQUAL( fc::parse_size( "10" ), 10 ); + BOOST_CHECK_EQUAL( fc::parse_size( "11" ), 11 ); + BOOST_CHECK_EQUAL( fc::parse_size( "12" ), 12 ); + + BOOST_CHECK_EQUAL( fc::parse_size( "314159265"), 314159265 ); + BOOST_CHECK_EQUAL( fc::parse_size( "1k" ), 1024 ); + BOOST_CHECK_THROW( fc::parse_size( "1a" ), fc::parse_error_exception ); + BOOST_CHECK_EQUAL( fc::parse_size( "1kb" ), 1000 ); + BOOST_CHECK_EQUAL( fc::parse_size( "1MiB" ), 1048576 ); + BOOST_CHECK_EQUAL( fc::parse_size( "32G" ), 34359738368 ); +} + /** * Verify that names are RFC-1035 compliant https://tools.ietf.org/html/rfc1035 * https://github.com/cryptonomex/graphene/issues/15