@@ -378,54 +378,55 @@ void check_children_of_bitasset(database& d, const asset_update_bitasset_operati
378
378
return ;
379
379
380
380
// loop through all assets that have this asset as a backing asset
381
- const auto & idx = d.get_index_type <asset_index>().indices ().get <by_type>();
382
-
383
- for ( auto itr = idx.lower_bound (true ); itr != idx.end (); ++itr )
384
- {
385
- const auto & child = *itr;
386
- if ( child.bitasset_data (d).options .short_backing_asset == op.asset_to_update )
387
- {
388
- if ( after_hf_922_931 )
381
+ const auto & idx = d.get_index_type <graphene::chain::asset_bitasset_data_index>()
382
+ .indices ()
383
+ .get <by_short_backing_asset>();
384
+ auto backed_range = idx.equal_range (op.asset_to_update );
385
+ std::for_each ( backed_range.first , backed_range.second ,
386
+ [after_hf_922_931, &new_backing_asset, &d, &op](const asset_bitasset_data_object& bitasset_data)
389
387
{
390
- FC_ASSERT ( child.get_id () != op.new_options .short_backing_asset ,
391
- " A BitAsset would be invalidated by changing this backing asset ('A' backed by 'B' backed by 'A')." );
388
+ const auto & child = bitasset_data.asset_id (d);
389
+ if ( after_hf_922_931 )
390
+ {
391
+ FC_ASSERT ( child.get_id () != op.new_options .short_backing_asset ,
392
+ " A BitAsset would be invalidated by changing this backing asset ('A' backed by 'B' backed by 'A')." );
392
393
393
- FC_ASSERT ( child.issuer != GRAPHENE_COMMITTEE_ACCOUNT,
394
- " A blockchain-controlled market asset would be invalidated by changing this backing asset." );
394
+ FC_ASSERT ( child.issuer != GRAPHENE_COMMITTEE_ACCOUNT,
395
+ " A blockchain-controlled market asset would be invalidated by changing this backing asset." );
395
396
396
- FC_ASSERT ( !new_backing_asset.is_market_issued (),
397
- " A non-blockchain controlled BitAsset would be invalidated by changing this backing asset." );
397
+ FC_ASSERT ( !new_backing_asset.is_market_issued (),
398
+ " A non-blockchain controlled BitAsset would be invalidated by changing this backing asset." );
398
399
399
- }
400
- else
401
- {
402
- if ( child.get_id () == op.new_options .short_backing_asset )
403
- {
404
- wlog ( " Before hf-922-931, modified an asset to be backed by another, but would cause a continuous "
405
- " loop. A cannot be backed by B which is backed by A." );
406
- return ;
407
- }
408
-
409
- if ( child.issuer == GRAPHENE_COMMITTEE_ACCOUNT )
410
- {
411
- wlog ( " before hf-922-931, modified an asset to be backed by a non-CORE, but this asset "
412
- " is a backing asset for a committee-issued asset. This occurred at block ${b}" ,
413
- (" b" , d.head_block_num ()));
414
- return ;
415
400
}
416
401
else
417
402
{
418
- if ( new_backing_asset.is_market_issued () ) { // a.k.a. !UIA
419
- wlog ( " before hf-922-931, modified an asset to be backed by an MPA, but this asset "
420
- " is a backing asset for another MPA, which would cause MPA backed by MPA backed by MPA. "
421
- " This occurred at block ${b}" ,
403
+ if ( child.get_id () == op.new_options .short_backing_asset )
404
+ {
405
+ wlog ( " Before hf-922-931, modified an asset to be backed by another, but would cause a continuous "
406
+ " loop. A cannot be backed by B which is backed by A." );
407
+ return ;
408
+ }
409
+
410
+ if ( child.issuer == GRAPHENE_COMMITTEE_ACCOUNT )
411
+ {
412
+ wlog ( " before hf-922-931, modified an asset to be backed by a non-CORE, but this asset "
413
+ " is a backing asset for a committee-issued asset. This occurred at block ${b}" ,
422
414
(" b" , d.head_block_num ()));
423
415
return ;
424
416
}
425
- } // if child.issuer
426
- } // if hf 922/931
427
- } // if this child is backed by the asset being adjusted
428
- } // for each asset
417
+ else
418
+ {
419
+ if ( new_backing_asset.is_market_issued () ) // a.k.a. !UIA
420
+ {
421
+ wlog ( " before hf-922-931, modified an asset to be backed by an MPA, but this asset "
422
+ " is a backing asset for another MPA, which would cause MPA backed by MPA backed by MPA. "
423
+ " This occurred at block ${b}" ,
424
+ (" b" , d.head_block_num ()));
425
+ return ;
426
+ }
427
+ } // if child.issuer
428
+ } // if hf 922/931
429
+ } ); // end of lambda and std::for_each()
429
430
} // check_children_of_bitasset
430
431
431
432
void_result asset_update_bitasset_evaluator::do_evaluate (const asset_update_bitasset_operation& op)
0 commit comments