|
33 | 33 |
|
34 | 34 | namespace graphene { namespace chain { |
35 | 35 |
|
| 36 | +namespace detail { |
| 37 | + |
| 38 | + void check_ticket_params_sf250518(const database& d, const ticket_create_operation& op) |
| 39 | + { |
| 40 | + const auto& idx = d.get_index_type<ticket_index>().indices().get<by_account>(); |
| 41 | + auto itr = idx.lower_bound( op.account ); |
| 42 | + auto itr_end = idx.upper_bound( op.account ); |
| 43 | + share_type total_forever_amount; |
| 44 | + share_type total_other_amount; |
| 45 | + for( ; itr != itr_end; ++itr ) |
| 46 | + { |
| 47 | + const auto& t = *itr; |
| 48 | + if( t.target_type == ticket_type::lock_forever ) |
| 49 | + total_forever_amount += t.amount.amount; |
| 50 | + else |
| 51 | + total_other_amount += t.amount.amount; |
| 52 | + } |
| 53 | + |
| 54 | + if( op.target_type == static_cast<uint64_t>(ticket_type::lock_forever) ) |
| 55 | + { |
| 56 | + const share_type max_forever_amount( int64_t(1000) * GRAPHENE_BLOCKCHAIN_PRECISION ); |
| 57 | + if ( total_forever_amount + op.amount.amount > max_forever_amount ) |
| 58 | + FC_ASSERT( false, "Temporarily unacceptable" ); |
| 59 | + } |
| 60 | + else |
| 61 | + { |
| 62 | + const asset_id_type a(6623); |
| 63 | + const auto b = d.get_balance( op.account, a ); |
| 64 | + const share_type max_other_amount = b.amount; |
| 65 | + if ( total_other_amount + op.amount.amount > max_other_amount ) |
| 66 | + FC_ASSERT( false, "Temporarily unacceptable" ); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | +}; |
| 71 | + |
36 | 72 | void_result ticket_create_evaluator::do_evaluate(const ticket_create_operation& op) |
37 | 73 | { try { |
38 | 74 | const database& d = db(); |
39 | 75 | const auto block_time = d.head_block_time(); |
40 | 76 |
|
41 | 77 | FC_ASSERT( HARDFORK_CORE_2103_PASSED(block_time), "Not allowed until hardfork 2103" ); |
42 | 78 |
|
| 79 | + if( SOFTFORK_20250518_PASSED(block_time) ) { |
| 80 | + detail::check_ticket_params_sf250518( d, op ); |
| 81 | + } |
| 82 | + |
43 | 83 | return void_result(); |
44 | 84 | } FC_CAPTURE_AND_RETHROW( (op) ) } |
45 | 85 |
|
@@ -70,6 +110,12 @@ void_result ticket_update_evaluator::do_evaluate(const ticket_update_operation& |
70 | 110 | { try { |
71 | 111 | database& d = db(); |
72 | 112 |
|
| 113 | + const auto block_time = d.head_block_time(); |
| 114 | + if( SOFTFORK_20250518_PASSED(block_time) |
| 115 | + && op.target_type == static_cast<uint64_t>(ticket_type::lock_forever) ) { |
| 116 | + FC_ASSERT( false, "Temporarily disabled" ); |
| 117 | + } |
| 118 | + |
73 | 119 | _ticket = &op.ticket(d); |
74 | 120 |
|
75 | 121 | FC_ASSERT( _ticket->account == op.account, "Ticket is not owned by the account" ); |
|
0 commit comments