예제 #1
0
void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o)
{ try {
   database& d = db();

   if( o.new_issuer ) FC_ASSERT(d.find_object(*o.new_issuer));

   const asset_object& a = o.asset_to_update(d);
   auto a_copy = a;
   a_copy.options = o.new_options;
   a_copy.validate();

   //There must be no bits set in o.permissions which are unset in a.issuer_permissions.
   FC_ASSERT(!(o.new_options.issuer_permissions & ~a.options.issuer_permissions),
             "Cannot reinstate previously revoked issuer permissions on an asset.");

   asset_to_update = &a;
   FC_ASSERT( o.issuer == a.issuer, "", ("o.issuer", o.issuer)("a.issuer", a.issuer) );

   const auto& chain_parameters = d.get_global_properties().parameters;

   FC_ASSERT( o.new_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
   for( auto id : o.new_options.whitelist_authorities )
      d.get_object(id);
   FC_ASSERT( o.new_options.blacklist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
   for( auto id : o.new_options.blacklist_authorities )
      d.get_object(id);

   return void_result();
} FC_CAPTURE_AND_RETHROW((o)) }
예제 #2
0
void_result asset_update_bitasset_evaluator::do_apply(const asset_update_bitasset_operation& o)
{
   db().modify(*bitasset_to_update, [&o](asset_bitasset_data_object& b) {
      b.options = o.new_options;
   });

   return void_result();
}
예제 #3
0
int replace_string_helper( EmacsSearch::sea_type RE, const EmacsString &prompt )
{
    //
    // perform either a query replace or a normal replace
    //
    int replaced = 0;
    int olddot = dot;

    EmacsString old;
    old = getstr( prompt );

    sea_glob.compile( old, RE );

    EmacsString new_string;
    if( ml_err )
        return 0;

    new_string = getstr("New string: ");

    int np = sea_glob.search( 1, dot );
    while( np > 0 )
    {
        set_dot( np );
        sea_glob.search_replace_once( new_string );
        replaced++;

        np = sea_glob.search( 1, dot );
#if 0
        // make sure the search actually moves on
        if( dot == np )
        {
            set_dot( dot + 1 );

            np = sea_glob.search( 1, dot );
        }
#endif
    }

    set_dot( olddot );

    if( replaced != 0 )
    {
        if( interactive() )
        {
            void_result();
            message( FormatString("Replaced %d occurrences") << replaced );
            cant_1line_opt = 1;
        }
        else
        {
            ml_value = replaced;
        }
    }
    else
        error( FormatString("No replacements done for \"%s\"") << last_search_string.asString() );

    return 0;
}
예제 #4
0
void_result asset_fund_fee_pool_evaluator::do_apply(const asset_fund_fee_pool_operation& o)
{
   db().adjust_balance(o.from_account, -o.amount);

   db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ) {
      data.fee_pool += o.amount;
   });

   return void_result();
}
예제 #5
0
void_result asset_fund_fee_pool_evaluator::do_evaluate(const asset_fund_fee_pool_operation& o)
{ try {
   database& d = db();

   const asset_object& a = o.asset_id(d);

   asset_dyn_data = &a.dynamic_asset_data_id(d);

   return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) }
예제 #6
0
void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_operation& o)
{ try {
   database& d = db();

   const asset_object& quote = o.asset_id(d);
   // Store medians for this asset
   d.modify(quote.bitasset_data(d), [&o,&d](asset_bitasset_data_object& a) {
      a.feeds[o.publisher] = make_pair(d.head_block_time(), o.feed);
      a.update_median_feeds(d.head_block_time());
   });

   return void_result();
   } FC_CAPTURE_AND_RETHROW((o)) }
예제 #7
0
void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_update_feed_producers_evaluator::operation_type& o)
{
   database& d = db();

   FC_ASSERT( o.new_feed_producers.size() <= d.get_global_properties().parameters.maximum_asset_feed_publishers );
   for( auto id : o.new_feed_producers )
      d.get_object(id);

   const asset_object& a = o.asset_to_update(d);

   FC_ASSERT(a.is_market_issued(), "Cannot update feed producers on a non-BitAsset.");
   FC_ASSERT(a.issuer != account_id_type(), "Cannot set feed producers on a genesis-issued asset.");

   const asset_bitasset_data_object& b = a.bitasset_data(d);
   bitasset_to_update = &b;
   FC_ASSERT( a.issuer == o.issuer );
   return void_result();
}
예제 #8
0
void_result asset_global_settle_evaluator::do_evaluate(const asset_global_settle_evaluator::operation_type& op)
{
   const database& d = db();
   asset_to_settle = &op.asset_to_settle(d);
   FC_ASSERT(asset_to_settle->is_market_issued());
   FC_ASSERT(asset_to_settle->can_global_settle());
   FC_ASSERT(asset_to_settle->issuer == op.issuer );
   FC_ASSERT(asset_to_settle->dynamic_data(d).current_supply > 0);
   const auto& idx = d.get_index_type<call_order_index>().indices().get<by_collateral>();
   assert( !idx.empty() );
   auto itr = idx.lower_bound(boost::make_tuple(price::min(asset_to_settle->bitasset_data(d).options.short_backing_asset,
                                                           op.asset_to_settle)));
   assert( itr != idx.end() && itr->debt_type() == op.asset_to_settle );
   const call_order_object& least_collateralized_short = *itr;
   FC_ASSERT(least_collateralized_short.get_debt() * op.settle_price <= least_collateralized_short.get_collateral(),
             "Cannot force settle at supplied price: least collateralized short lacks sufficient collateral to settle.");

   return void_result();
}
예제 #9
0
void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bitasset_operation& o)
{
   database& d = db();

   const asset_object& a = o.asset_to_update(d);

   FC_ASSERT(a.is_market_issued(), "Cannot update BitAsset-specific settings on a non-BitAsset.");

   const asset_bitasset_data_object& b = a.bitasset_data(d);
   if( o.new_options.short_backing_asset != b.options.short_backing_asset )
   {
      FC_ASSERT(a.dynamic_asset_data_id(d).current_supply == 0);
      FC_ASSERT(d.find_object(o.new_options.short_backing_asset));
   }

   bitasset_to_update = &b;
   FC_ASSERT( o.issuer == a.issuer, "", ("o.issuer", o.issuer)("a.issuer", a.issuer) );

   return void_result();
}
예제 #10
0
void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_operation& o)
{ try {
   database& d = db();

   const asset_object& quote = o.asset_id(d);
   //Verify that this feed is for a market-issued asset and that asset is backed by the base
   FC_ASSERT(quote.is_market_issued());

   const asset_bitasset_data_object& bitasset = quote.bitasset_data(d);
   FC_ASSERT(bitasset.options.short_backing_asset == o.feed.call_limit.base.asset_id);
   //Verify that the publisher is authoritative to publish a feed
   if( quote.issuer == account_id_type() )
   {
      //It's a delegate-fed asset. Verify that publisher is an active delegate or witness.
      FC_ASSERT(d.get(account_id_type()).active.auths.count(o.publisher) ||
                d.get_global_properties().witness_accounts.count(o.publisher));
   } else {
      FC_ASSERT(bitasset.feeds.count(o.publisher));
   }

   return void_result();
} FC_CAPTURE_AND_RETHROW((o)) }
예제 #11
0
void_result asset_update_feed_producers_evaluator::do_apply(const asset_update_feed_producers_evaluator::operation_type& o)
{
   db().modify(*bitasset_to_update, [&](asset_bitasset_data_object& a) {
      //This is tricky because I have a set of publishers coming in, but a map of publisher to feed is stored.
      //I need to update the map such that the keys match the new publishers, but not munge the old price feeds from
      //publishers who are being kept.
      //First, remove any old publishers who are no longer publishers
      for( auto itr = a.feeds.begin(); itr != a.feeds.end(); )
      {
         if( !o.new_feed_producers.count(itr->first) )
            itr = a.feeds.erase(itr);
         else
            ++itr;
      }
      //Now, add any new publishers
      for( auto itr = o.new_feed_producers.begin(); itr != o.new_feed_producers.end(); ++itr )
         if( !a.feeds.count(*itr) )
            a.feeds[*itr];
      a.update_median_feeds(db().head_block_time());
   });

   return void_result();
}
예제 #12
0
void_result asset_update_evaluator::do_apply(const asset_update_operation& o)
{
   database& d = db();

   // If we are now disabling force settlements, cancel all open force settlement orders
   if( o.new_options.flags & disable_force_settle && asset_to_update->can_force_settle() )
   {
      const auto& idx = d.get_index_type<force_settlement_index>().indices().get<by_expiration>();
      // Funky iteration code because we're removing objects as we go. We have to re-initialize itr every loop instead
      // of simply incrementing it.
      for( auto itr = idx.lower_bound(o.asset_to_update);
           itr != idx.end() && itr->settlement_asset_id() == o.asset_to_update;
           itr = idx.lower_bound(o.asset_to_update) )
         d.cancel_order(*itr);
   }

   d.modify(*asset_to_update, [&](asset_object& a) {
      if( o.new_issuer )
         a.issuer = *o.new_issuer;
      a.options = o.new_options;
   });

   return void_result();
}
예제 #13
0
void_result asset_global_settle_evaluator::do_apply(const asset_global_settle_evaluator::operation_type& op)
{
   database& d = db();
   d.globally_settle_asset( op.asset_to_settle(db()), op.settle_price );
   return void_result();
}
예제 #14
0
 void_result do_apply( const custom_operation& o ){ return void_result(); }
예제 #15
0
 void_result do_evaluate( const custom_operation& o ){ return void_result(); }