示例#1
0
typename basic_template<H,F,O,A>::operation::recv basic_template<H,F,O,A>::operation::recv::operator () (const aio::buffer& b, int f, callback_t cb, const arg_t& a, const aio::timeout& tm) const
{
get_buffer() = b;
get_flags() = f;
get_callback() = cb;
get_arg() = a;
get_timeout() = tm;
return *this;
}
示例#2
0
 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;
 }
示例#3
0
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 ) );
}
示例#4
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();
 }
示例#5
0
operation_result database::apply_operation(transaction_evaluation_state& eval_state, const operation& op)
{ try {
   int i_which = op.which();
   uint64_t u_which = uint64_t( i_which );
   FC_ASSERT( i_which >= 0, "Negative operation tag in operation ${op}", ("op",op) );
   FC_ASSERT( u_which < _operation_evaluators.size(), "No registered evaluator for operation ${op}", ("op",op) );
   unique_ptr<op_evaluator>& eval = _operation_evaluators[ u_which ];
   FC_ASSERT( eval, "No registered evaluator for operation ${op}", ("op",op) );
   auto op_id = push_applied_operation( op );
   auto result = eval->evaluate( eval_state, op, true );
   set_applied_operation_result( op_id, result );
   return result;
} FC_CAPTURE_AND_RETHROW( (op) ) }
示例#6
0
operation_result database::apply_operation(transaction_evaluation_state& eval_state, const operation& op)
{ try {
   int i_which = op.which();
   uint64_t u_which = uint64_t( i_which );
   if( i_which < 0 )
      assert( "Negative operation tag" && false );
   if( u_which >= _operation_evaluators.size() )
      assert( "No registered evaluator for this operation" && false );
   unique_ptr<op_evaluator>& eval = _operation_evaluators[ u_which ];
   if( !eval )
      assert( "No registered evaluator for this operation" && false );
   auto op_id = push_applied_operation( op );
   auto result = eval->evaluate( eval_state, op, true );
   set_applied_operation_result( op_id, result );
   return result;
} FC_CAPTURE_AND_RETHROW( (op) ) }
   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;
   }
 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;
 }
示例#9
0
 void validate(const operation &o, const options_type &opts) {
     o.visit(validate_operation_visitor(opts));
 }
示例#10
0
 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;
 }
示例#11
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);
 }
 calc_fee_visitor( const fee_schedule& p, const operation& op ):param(p),current_op(op.which()){}
示例#13
0
void operation_validate( const operation& op )
{
   op.visit( operation_validator() );
}
示例#14
0
void operation_get_required_authorities( const operation& op, vector<authority>& result )
{
   op.visit( required_auth_visitor( result ) );
}
示例#15
0
typename basic_template<H,F,O,A>::operation::recv::data_t& basic_template<H,F,O,A>::operation::recv::get_privdata() const
{
return get_data().u.recv;
}
示例#16
0
basic_template<H,F,O,A>::operation::recv::recv(operation op):
    operation( op )
{
get_data().m_interface = &get_data().m_fdata->m_interface->recv;
}