コード例 #1
0
ファイル: operations.cpp プロジェクト: clar/graphene
void operation_get_required_authorities( const operation& op, 
                                         flat_set<account_id_type>& active,
                                         flat_set<account_id_type>& owner,
                                         vector<authority>&  other )
{
   op.visit( operation_get_required_auth( active, owner, other ) );
}
コード例 #2
0
 void apply(database &db, const operation &o, const options_type &opts) {
     auto undo_session = db.start_undo_session(!(opts &
                                                 skip_undo_operation));
     db.pre_apply_operation(o);
     o.visit(apply_operation_visitor(db, opts));
     db.post_apply_operation(o);
     undo_session.squash();
 }
コード例 #3
0
ファイル: fee_schedule.cpp プロジェクト: sfinder/graphene
 asset fee_schedule::calculate_fee( const operation& op, const price& core_exchange_rate )const
 {
    //idump( (op)(core_exchange_rate) );
    fee_parameters params; params.set_which(op.which());
    auto itr = parameters.find(params);
    if( itr != parameters.end() ) params = *itr;
    auto base_value = op.visit( calc_fee_visitor( params ) );
    auto scaled = fc::uint128(base_value) * scale;
    scaled /= GRAPHENE_100_PERCENT;
    FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY );
    auto result = asset( scaled.to_uint64(), 0 ) * core_exchange_rate;
    FC_ASSERT( result.amount <= GRAPHENE_MAX_SHARE_SUPPLY );
    return result;
 }
コード例 #4
0
   asset fee_schedule::calculate_fee( const operation& op, const price& core_exchange_rate )const
   {
      auto base_value = op.visit( calc_fee_visitor( *this, op ) );
      auto scaled = fc::uint128(base_value) * scale;
      scaled /= GRAPHENE_100_PERCENT;
      FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY );
      //idump( (base_value)(scaled)(core_exchange_rate) );
      auto result = asset( scaled.to_uint64(), asset_id_type(0) ) * core_exchange_rate;
      //FC_ASSERT( result * core_exchange_rate >= asset( scaled.to_uint64()) );

      while( result * core_exchange_rate < asset( scaled.to_uint64()) )
        result.amount++;

      FC_ASSERT( result.amount <= GRAPHENE_MAX_SHARE_SUPPLY );
      return result;
   }
コード例 #5
0
 asset fee_schedule::set_fee( operation& op, const price& core_exchange_rate )const
 {
    auto f = calculate_fee( op, core_exchange_rate );
    auto f_max = f;
    for( int i=0; i<MAX_FEE_STABILIZATION_ITERATION; i++ )
    {
       op.visit( set_fee_visitor( f_max ) );
       auto f2 = calculate_fee( op, core_exchange_rate );
       if( f == f2 )
          break;
       f_max = std::max( f_max, f2 );
       f = f2;
       if( i == 0 )
       {
          // no need for warnings on later iterations
          wlog( "set_fee requires multiple iterations to stabilize with core_exchange_rate ${p} on operation ${op}",
             ("p", core_exchange_rate) ("op", op) );
       }
    }
    return f_max;
 }
コード例 #6
0
 void validate(const operation &o, const options_type &opts) {
     o.visit(validate_operation_visitor(opts));
 }
コード例 #7
0
ファイル: fee_schedule.cpp プロジェクト: sfinder/graphene
 asset fee_schedule::set_fee( operation& op, const price& core_exchange_rate )const
 {
    auto f = calculate_fee( op, core_exchange_rate );
    op.visit( set_fee_visitor( f ) );
    return f;
 }
コード例 #8
0
 void operation_get_impacted_accounts(const operation &op, flat_set<account_name_type> &result) {
     get_impacted_account_visitor vtor = get_impacted_account_visitor(result);
     op.visit(vtor);
 }
コード例 #9
0
ファイル: operations.cpp プロジェクト: clar/graphene
void operation_validate( const operation& op )
{
   op.visit( operation_validator() );
}
コード例 #10
0
ファイル: operations.cpp プロジェクト: clar/graphene
void operation_get_required_authorities( const operation& op, vector<authority>& result )
{
   op.visit( required_auth_visitor( result ) );
}