17
17
#include < graphene/chain/vesting_balance_object.hpp>
18
18
#include < graphene/chain/transaction_history_object.hpp>
19
19
#include < graphene/chain/impacted.hpp>
20
+ #include < graphene/chain/hardfork.hpp>
20
21
21
22
using namespace fc ;
22
23
using namespace graphene ::chain;
@@ -25,8 +26,13 @@ using namespace graphene::chain;
25
26
struct get_impacted_account_visitor
26
27
{
27
28
flat_set<account_id_type>& _impacted;
28
- get_impacted_account_visitor ( flat_set<account_id_type>& impact ):_impacted(impact) {}
29
- typedef void result_type;
29
+ bool _ignore_custom_op_reqd_auths;
30
+
31
+ get_impacted_account_visitor ( flat_set<account_id_type>& impact, bool ignore_custom_operation_required_auths )
32
+ : _impacted( impact ), _ignore_custom_op_reqd_auths( ignore_custom_operation_required_auths )
33
+ {}
34
+
35
+ using result_type = void ;
30
36
31
37
void operator ()( const transfer_operation& op )
32
38
{
@@ -154,7 +160,7 @@ struct get_impacted_account_visitor
154
160
_impacted.insert ( op.fee_payer () ); // fee_paying_account
155
161
vector<authority> other;
156
162
for ( const auto & proposed_op : op.proposed_ops )
157
- operation_get_required_authorities ( proposed_op.op , _impacted, _impacted, other );
163
+ operation_get_required_authorities ( proposed_op.op , _impacted, _impacted, other, _ignore_custom_op_reqd_auths );
158
164
for ( auto & o : other )
159
165
add_authority_accounts ( _impacted, o );
160
166
}
@@ -214,6 +220,8 @@ struct get_impacted_account_visitor
214
220
void operator ()( const custom_operation& op )
215
221
{
216
222
_impacted.insert ( op.fee_payer () ); // payer
223
+ if ( !_ignore_custom_op_reqd_auths )
224
+ _impacted.insert ( op.required_auths .begin (), op.required_auths .end () );
217
225
}
218
226
void operator ()( const assert_operation& op )
219
227
{
@@ -283,20 +291,17 @@ struct get_impacted_account_visitor
283
291
}
284
292
};
285
293
286
- void graphene::chain::operation_get_impacted_accounts ( const operation& op, flat_set<account_id_type>& result )
287
- {
288
- get_impacted_account_visitor vtor = get_impacted_account_visitor ( result );
294
+ void graphene::chain::operation_get_impacted_accounts ( const operation& op, flat_set<account_id_type>& result, bool ignore_custom_operation_required_auths ) {
295
+ get_impacted_account_visitor vtor = get_impacted_account_visitor ( result, ignore_custom_operation_required_auths );
289
296
op.visit ( vtor );
290
297
}
291
298
292
- void graphene::chain::transaction_get_impacted_accounts ( const transaction& tx, flat_set<account_id_type>& result )
293
- {
299
+ void graphene::chain::transaction_get_impacted_accounts ( const transaction& tx, flat_set<account_id_type>& result, bool ignore_custom_operation_required_auths ) {
294
300
for ( const auto & op : tx.operations )
295
- operation_get_impacted_accounts ( op, result );
301
+ operation_get_impacted_accounts ( op, result, ignore_custom_operation_required_auths );
296
302
}
297
303
298
- void get_relevant_accounts ( const object* obj, flat_set<account_id_type>& accounts )
299
- {
304
+ void get_relevant_accounts ( const object* obj, flat_set<account_id_type>& accounts, bool ignore_custom_operation_required_auths ) {
300
305
if ( obj->id .space () == protocol_ids )
301
306
{
302
307
switch ( (object_type)obj->id .type () )
@@ -342,12 +347,14 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
342
347
} case proposal_object_type:{
343
348
const auto & aobj = dynamic_cast <const proposal_object*>(obj);
344
349
FC_ASSERT ( aobj != nullptr );
345
- transaction_get_impacted_accounts ( aobj->proposed_transaction , accounts );
350
+ transaction_get_impacted_accounts ( aobj->proposed_transaction , accounts,
351
+ ignore_custom_operation_required_auths );
346
352
break ;
347
353
} case operation_history_object_type:{
348
354
const auto & aobj = dynamic_cast <const operation_history_object*>(obj);
349
355
FC_ASSERT ( aobj != nullptr );
350
- operation_get_impacted_accounts ( aobj->op , accounts );
356
+ operation_get_impacted_accounts ( aobj->op , accounts,
357
+ ignore_custom_operation_required_auths );
351
358
break ;
352
359
} case withdraw_permission_object_type:{
353
360
const auto & aobj = dynamic_cast <const withdraw_permission_object*>(obj);
@@ -404,7 +411,8 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
404
411
} case impl_transaction_history_object_type:{
405
412
const auto & aobj = dynamic_cast <const transaction_history_object*>(obj);
406
413
FC_ASSERT ( aobj != nullptr );
407
- transaction_get_impacted_accounts ( aobj->trx , accounts );
414
+ transaction_get_impacted_accounts ( aobj->trx , accounts,
415
+ ignore_custom_operation_required_auths );
408
416
break ;
409
417
} case impl_blinded_balance_object_type:{
410
418
const auto & aobj = dynamic_cast <const blinded_balance_object*>(obj);
@@ -458,6 +466,7 @@ void database::notify_changed_objects()
458
466
if ( _undo_db.enabled () )
459
467
{
460
468
const auto & head_undo = _undo_db.head ();
469
+ auto chain_time = head_block_time ();
461
470
462
471
// New
463
472
if ( !new_objects.empty () )
@@ -469,7 +478,8 @@ void database::notify_changed_objects()
469
478
new_ids.push_back (item);
470
479
auto obj = find_object (item);
471
480
if (obj != nullptr )
472
- get_relevant_accounts (obj, new_accounts_impacted);
481
+ get_relevant_accounts (obj, new_accounts_impacted,
482
+ MUST_IGNORE_CUSTOM_OP_REQD_AUTHS (chain_time));
473
483
}
474
484
475
485
if ( new_ids.size () )
@@ -484,7 +494,8 @@ void database::notify_changed_objects()
484
494
for ( const auto & item : head_undo.old_values )
485
495
{
486
496
changed_ids.push_back (item.first );
487
- get_relevant_accounts (item.second .get (), changed_accounts_impacted);
497
+ get_relevant_accounts (item.second .get (), changed_accounts_impacted,
498
+ MUST_IGNORE_CUSTOM_OP_REQD_AUTHS (chain_time));
488
499
}
489
500
490
501
if ( changed_ids.size () )
@@ -502,11 +513,12 @@ void database::notify_changed_objects()
502
513
removed_ids.emplace_back ( item.first );
503
514
auto obj = item.second .get ();
504
515
removed.emplace_back ( obj );
505
- get_relevant_accounts (obj, removed_accounts_impacted);
516
+ get_relevant_accounts (obj, removed_accounts_impacted,
517
+ MUST_IGNORE_CUSTOM_OP_REQD_AUTHS (chain_time));
506
518
}
507
519
508
520
if ( removed_ids.size () )
509
- GRAPHENE_TRY_NOTIFY ( removed_objects, removed_ids, removed, removed_accounts_impacted)
521
+ GRAPHENE_TRY_NOTIFY ( removed_objects, removed_ids, removed, removed_accounts_impacted )
510
522
}
511
523
}
512
524
} FC_CAPTURE_AND_LOG ( (0 ) ) }
0 commit comments