• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ asset类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中asset的典型用法代码示例。如果您正苦于以下问题:C++ asset类的具体用法?C++ asset怎么用?C++ asset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了asset类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1:

price operator/(const asset &base, const asset &quote) {
    try {
        FC_ASSERT(base.symbol_name() != quote.symbol_name());
        return price{base, quote};
    }
    FC_CAPTURE_AND_RETHROW((base)(quote))
}
开发者ID:Rsteem,项目名称:steem,代码行数:7,代码来源:asset.cpp


示例2: add_output_delegate_votes

 void block_evaluation_state::add_output_delegate_votes( int32_t did, const asset& votes )
 {
    auto itr = _output_votes.find(did);
    if( itr == _output_votes.end() )
       _output_votes[did] = votes.get_rounded_amount();
    else
       itr->second += votes.get_rounded_amount();
 }
开发者ID:suykerbuyk,项目名称:bitshares_toolkit,代码行数:8,代码来源:transaction_validator.cpp


示例3: issue

void token::issue( account_name to, asset quantity, string memo )
{
    auto sym = quantity.symbol;
    eosio_assert( sym.is_valid(), "invalid symbol name" );
    eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" );

    auto sym_name = sym.name();
    stats statstable( _self, sym_name );
    auto existing = statstable.find( sym_name );
    eosio_assert( existing != statstable.end(), "token with symbol does not exist, create token before issue" );
    const auto& st = *existing;

    require_auth( st.issuer );
    eosio_assert( quantity.is_valid(), "invalid quantity" );
    eosio_assert( quantity.amount > 0, "must issue positive quantity" );

    eosio_assert( quantity.symbol == st.supply.symbol, "symbol precision mismatch" );
    eosio_assert( quantity.amount <= st.max_supply.amount - st.supply.amount, "quantity exceeds available supply");

    statstable.modify( st, 0, [&]( auto& s ) {
       s.supply += quantity;
    });

    add_balance( st.issuer, quantity, st.issuer );

    if( to != st.issuer ) {
       SEND_INLINE_ACTION( *this, transfer, {st.issuer,N(active)}, {st.issuer, to, quantity, memo} );
    }
}
开发者ID:sgerov,项目名称:eos,代码行数:29,代码来源:eosio.token.cpp


示例4: pretty

string database_fixture::pretty( const asset& a )const
{
  std::stringstream ss;
  ss << a.amount.value << " ";
  ss << a.asset_id(db).symbol;
  return ss.str();
}
开发者ID:sfinder,项目名称:graphene,代码行数:7,代码来源:database_fixture.cpp


示例5: op

void database_fixture::issue_uia( const account_object& recipient, asset amount )
{
   asset_issue_operation op({asset(),amount.asset_id(db).issuer, amount, recipient.id});
   trx.validate();
   trx.operations.push_back(op);
   return;
}
开发者ID:NaturalCoder,项目名称:graphene,代码行数:7,代码来源:database_fixture.cpp


示例6: asset

uint16_t trx_validation_state::find_unused_sig_output( const address& owner, const asset& bal )
{
  auto rounded_amount = asset(bal.get_rounded_amount(),bal.unit);
  ilog( "find unused sig output ${o}  ${bal}", ("o", owner)("bal",bal) );
  for( uint32_t i = 0; i < trx.outputs.size(); ++i )
  {
     if( used_outputs.find(i) == used_outputs.end() )
     {
        ilog( "out: ${i}", ("i",trx.outputs[i]) );
        if( trx.outputs[i].claim_func == claim_by_signature )
        {
           ilog( "amount: ${i} ==? ${r} ", ("i",trx.outputs[i].get_amount())("r",rounded_amount) );
           ilog( "round down amount: ${i} ==? ${r} ", ("i",trx.outputs[i].amount/5)("r",rounded_amount.amount.high_bits()/5) );
           if( trx.outputs[i].amount/5 == rounded_amount.amount.high_bits()/5 && trx.outputs[i].unit == bal.unit )
           {
              if( trx.outputs[i].as<claim_by_signature_output>().owner == owner )
              {
                 return i;
              }
           }
        }
     }
  }
  return output_not_found;
}
开发者ID:Doken-Tokuyama,项目名称:BitShares,代码行数:25,代码来源:trx_validation_state.cpp


示例7: asset

uint64_t database_fixture::fund(
   const account_object& account,
   const asset& amount /* = asset(500000) */
   )
{
   transfer(account_id_type()(db), account, amount);
   return get_balance(account, amount.asset_id(db));
}
开发者ID:sfinder,项目名称:graphene,代码行数:8,代码来源:database_fixture.cpp


示例8: FC_ASSERT

asset operator*(const asset &a, const price &b) {
    if (a.symbol_name() == b.base.symbol_name()) {
        FC_ASSERT(b.base.amount.value > 0);
        uint128_t result =
            (uint128_t(a.amount.value) * b.quote.amount.value) /
            b.base.amount.value;
        FC_ASSERT(result.hi == 0);
        return asset(result.to_uint64(), b.quote.symbol);
    } else if (a.symbol_name() == b.quote.symbol_name()) {
        FC_ASSERT(b.quote.amount.value > 0);
        uint128_t result =
            (uint128_t(a.amount.value) * b.base.amount.value) /
            b.quote.amount.value;
        FC_ASSERT(result.hi == 0);
        return asset(result.to_uint64(), b.base.symbol);
    }
    FC_THROW_EXCEPTION(fc::assert_exception, "invalid asset * price", ("asset", a)("price", b));
}
开发者ID:Rsteem,项目名称:steem,代码行数:18,代码来源:asset.cpp


示例9: FC_ASSERT

 asset operator * ( const asset& a, const price& b )
 {
    if( a.symbol_name() == b.base.symbol_name() )
    {
       FC_ASSERT( b.base.amount.value > 0 );
       uint128_t result = (uint128_t(a.amount.value) * b.quote.amount.value)/b.base.amount.value;
       FC_ASSERT( result <= uint64_t(-1) );
       return asset( result.to_uint64(), b.quote.symbol );
    }
    else if( a.symbol_name() == b.quote.symbol_name() )
    {
       FC_ASSERT( b.quote.amount.value > 0 );
       uint128_t result = (uint128_t(a.amount.value) * b.base.amount.value)/b.quote.amount.value;
       //FC_ASSERT( result <= STEEMIT_MAX_SHARE_SUPPLY, "${result}", ("result",result)("max",STEEMIT_MAX_SHARE_SUPPLY)("asset",a)("price",b) );
       FC_ASSERT( result <= uint64_t(-1) );
       return asset( result.to_uint64(), b.base.symbol );
    }
    FC_THROW_EXCEPTION( fc::assert_exception, "invalid asset * price", ("asset",a)("price",b) );
 }
开发者ID:pharesim,项目名称:steem,代码行数:19,代码来源:asset.cpp


示例10: BOOST_TEST_MESSAGE

void database_fixture::issue_uia( const account_object& recipient, asset amount )
{
   BOOST_TEST_MESSAGE( "Issuing UIA" );
   asset_issue_operation op;
   op.issuer = amount.asset_id(db).issuer;
   op.asset_to_issue = amount;
   op.issue_to_account = recipient.id;
   trx.operations.push_back(op);
   db.push_transaction( trx, ~0 );
   trx.operations.clear();
}
开发者ID:sfinder,项目名称:graphene,代码行数:11,代码来源:database_fixture.cpp


示例11: FC_ASSERT

bool database::fill_order( const call_order_object& order, const asset& pays, const asset& receives )
{ try {
   //idump((pays)(receives)(order));
   FC_ASSERT( order.get_debt().asset_id == receives.asset_id );
   FC_ASSERT( order.get_collateral().asset_id == pays.asset_id );
   FC_ASSERT( order.get_collateral() >= pays );

   optional<asset> collateral_freed;
   modify( order, [&]( call_order_object& o ){
            o.debt       -= receives.amount;
            o.collateral -= pays.amount;
            if( o.debt == 0 )
            {
              collateral_freed = o.get_collateral();
              o.collateral = 0;
            }
       });
   const asset_object& mia = receives.asset_id(*this);
   assert( mia.is_market_issued() );

   const asset_dynamic_data_object& mia_ddo = mia.dynamic_asset_data_id(*this);

   modify( mia_ddo, [&]( asset_dynamic_data_object& ao ){
       //idump((receives));
        ao.current_supply -= receives.amount;
      });

   const account_object& borrower = order.borrower(*this);
   if( collateral_freed || pays.asset_id == asset_id_type() )
   {
      const account_statistics_object& borrower_statistics = borrower.statistics(*this);
      if( collateral_freed )
         adjust_balance(borrower.get_id(), *collateral_freed);

      modify( borrower_statistics, [&]( account_statistics_object& b ){
              if( collateral_freed && collateral_freed->amount > 0 )
                b.total_core_in_orders -= collateral_freed->amount;
              if( pays.asset_id == asset_id_type() )
                b.total_core_in_orders -= pays.amount;

              assert( b.total_core_in_orders >= 0 );
           });
   }

   assert( pays.asset_id != receives.asset_id );
   push_applied_operation( fill_order_operation{ order.id, order.borrower, pays, receives, asset(0, pays.asset_id) } );

   if( collateral_freed )
      remove( order );

   return collateral_freed.valid();
} FC_CAPTURE_AND_RETHROW( (order)(pays)(receives) ) }
开发者ID:techsharesteam,项目名称:techshares,代码行数:52,代码来源:db_market.cpp


示例12: FC_ASSERT

bool database::fill_order( const limit_order_object& order, const asset& pays, const asset& receives )
{ try {
   FC_ASSERT( order.amount_for_sale().asset_id == pays.asset_id );
   FC_ASSERT( pays.asset_id != receives.asset_id );

   const account_object& seller = order.seller(*this);
   const asset_object& recv_asset = receives.asset_id(*this);

   auto issuer_fees = pay_market_fees( recv_asset, receives );
   pay_order( seller, receives - issuer_fees, pays );

   assert( pays.asset_id != receives.asset_id );
   push_applied_operation( fill_order_operation( order.id, order.seller, pays, receives, issuer_fees ) );

   // conditional because cheap integer comparison may allow us to avoid two expensive modify() and object lookups
   if( order.deferred_fee > 0 )
   {
      modify( seller.statistics(*this), [&]( account_statistics_object& statistics )
      {
         statistics.pay_fee( order.deferred_fee, get_global_properties().parameters.cashback_vesting_threshold );
      } );
   }

   if( pays == order.amount_for_sale() )
   {
      remove( order );
      return true;
   }
   else
   {
      modify( order, [&]( limit_order_object& b ) {
                             b.for_sale -= pays.amount;
                             b.deferred_fee = 0;
                          });
      /**
       *  There are times when the AMOUNT_FOR_SALE * SALE_PRICE == 0 which means that we
       *  have hit the limit where the seller is asking for nothing in return.  When this
       *  happens we must refund any balance back to the seller, it is too small to be
       *  sold at the sale price.
       */
      if( order.amount_to_receive().amount == 0 )
      {
         cancel_order(order);
         return true;
      }
      return false;
   }
} FC_CAPTURE_AND_RETHROW( (order)(pays)(receives) ) }
开发者ID:clar,项目名称:graphene,代码行数:48,代码来源:db_market.cpp


示例13: deposit

	void deposit( const account_name from, const asset& quantity )
	{
		eosio_assert( quantity.is_valid(), "invalid quantiy" );
		eosio_assert( quantity.amount > 0, "must deposit positive quantity" );
		action
		(
			permission_level
			{
				from, N( active )
			},
			N( eosio.token ), 
			N( transfer ),
			std::make_tuple( from, _self, quantity, std::string("") )
		).send();
		
		return;
	}
开发者ID:lycion,项目名称:eos_source_test_01,代码行数:17,代码来源:work01.cpp


示例14: create

void token::create( account_name issuer,
                    asset        maximum_supply )
{
    require_auth( _self );

    auto sym = maximum_supply.symbol;
    eosio_assert( sym.is_valid(), "invalid symbol name" );
    eosio_assert( maximum_supply.is_valid(), "invalid supply");
    eosio_assert( maximum_supply.amount > 0, "max-supply must be positive");

    stats statstable( _self, sym.name() );
    auto existing = statstable.find( sym.name() );
    eosio_assert( existing == statstable.end(), "token with symbol already exists" );

    statstable.emplace( _self, [&]( auto& s ) {
       s.supply.symbol = maximum_supply.symbol;
       s.max_supply    = maximum_supply;
       s.issuer        = issuer;
    });
}
开发者ID:sgerov,项目名称:eos,代码行数:20,代码来源:eosio.token.cpp


示例15: deposit

      //@abi action
      void deposit( const account_name from, const asset& quantity ) {
         
         eosio_assert( quantity.is_valid(), "invalid quantity" );
         eosio_assert( quantity.amount > 0, "must deposit positive quantity" );

         auto itr = accounts.find(from);
         if( itr == accounts.end() ) {
            itr = accounts.emplace(_self, [&](auto& acnt){
               acnt.owner = from;
            });
         }

         action(
            permission_level{ from, N(active) },
            N(eosio.token), N(transfer),
            std::make_tuple(from, _self, quantity, std::string(""))
         ).send();

         accounts.modify( itr, 0, [&]( auto& acnt ) {
            acnt.eos_balance += quantity;
         });
      }
开发者ID:108518,项目名称:eos,代码行数:23,代码来源:dice.cpp


示例16: assert

bool database::fill_order( const limit_order_object& order, const asset& pays, const asset& receives )
{
   assert( order.amount_for_sale().asset_id == pays.asset_id );
   assert( pays.asset_id != receives.asset_id );

   const account_object& seller = order.seller(*this);
   const asset_object& recv_asset = receives.asset_id(*this);

   auto issuer_fees = pay_market_fees( recv_asset, receives );
   pay_order( seller, receives - issuer_fees, pays );

   assert( pays.asset_id != receives.asset_id );
   push_applied_operation( fill_order_operation( order.id, order.seller, pays, receives, issuer_fees ) );

   if( pays == order.amount_for_sale() )
   {
      remove( order );
      return true;
   }
   else
   {
      modify( order, [&]( limit_order_object& b ) {
                             b.for_sale -= pays.amount;
                          });
      /**
       *  There are times when the AMOUNT_FOR_SALE * SALE_PRICE == 0 which means that we
       *  have hit the limit where the seller is asking for nothing in return.  When this
       *  happens we must refund any balance back to the seller, it is too small to be
       *  sold at the sale price.
       */
      if( order.amount_to_receive().amount == 0 )
      {
         cancel_order(order);
         return true;
      }
      return false;
   }
}
开发者ID:sfinder,项目名称:graphene,代码行数:38,代码来源:db_market.cpp


示例17: withdraw

      //@abi action
      void withdraw( const account_name to, const asset& quantity ) {
         require_auth( to );

         eosio_assert( quantity.is_valid(), "invalid quantity" );
         eosio_assert( quantity.amount > 0, "must withdraw positive quantity" );

         auto itr = accounts.find( to );
         eosio_assert(itr != accounts.end(), "unknown account");

         accounts.modify( itr, 0, [&]( auto& acnt ) {
            eosio_assert( acnt.eos_balance >= quantity, "insufficient balance" );
            acnt.eos_balance -= quantity;
         });

         action(
            permission_level{ _self, N(active) },
            N(eosio.token), N(transfer),
            std::make_tuple(_self, to, quantity, std::string(""))
         ).send();

         if( itr->is_empty() ) {
            accounts.erase(itr);
         }
      }
开发者ID:108518,项目名称:eos,代码行数:25,代码来源:dice.cpp


示例18: transfer

void token::transfer( account_name from,
                      account_name to,
                      asset        quantity,
                      string       memo )
{
    eosio_assert( from != to, "cannot transfer to self" );
    require_auth( from );
    eosio_assert( is_account( to ), "to account does not exist");
    auto sym = quantity.symbol.name();
    stats statstable( _self, sym );
    const auto& st = statstable.get( sym );

    require_recipient( from );
    require_recipient( to );

    eosio_assert( quantity.is_valid(), "invalid quantity" );
    eosio_assert( quantity.amount > 0, "must transfer positive quantity" );
    eosio_assert( quantity.symbol == st.supply.symbol, "symbol precision mismatch" );
    eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" );


    sub_balance( from, quantity );
    add_balance( to, quantity, from );
}
开发者ID:sgerov,项目名称:eos,代码行数:24,代码来源:eosio.token.cpp


示例19: EOS_ASSERT

 friend asset operator + (const asset& a, const asset& b) {
    EOS_ASSERT(a.get_symbol() == b.get_symbol(), asset_type_exception, "addition between two different asset is not allowed");
    return asset(a.amount + b.amount, a.get_symbol());
 }
开发者ID:milk57618,项目名称:eos,代码行数:4,代码来源:asset.hpp


示例20: tie

 friend bool operator == (const asset& a, const asset& b)
 {
    return std::tie(a.get_symbol(), a.amount) == std::tie(b.get_symbol(), b.amount);
 }
开发者ID:milk57618,项目名称:eos,代码行数:4,代码来源:asset.hpp



注:本文中的asset类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ast_manager类代码示例发布时间:2022-05-31
下一篇:
C++ asio类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap