当前位置: 首页>>代码示例>>C++>>正文


C++ FC_ASSERT函数代码示例

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


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

示例1: scaled_precision

 static share_type scaled_precision( uint8_t precision )
 {
    FC_ASSERT( precision < 19 );
    return scaled_precision_lut[ precision ];
 }
开发者ID:clar,项目名称:graphene,代码行数:5,代码来源:asset.hpp

示例2: ntp_error

fc::microseconds ntp_error()
{
  fc::optional<fc::time_point> current_ntp_time = ntp_time();
  FC_ASSERT( current_ntp_time, "We don't have NTP time!" );
  return *current_ntp_time - fc::time_point::now();
}
开发者ID:BitMoneta,项目名称:bitshares,代码行数:6,代码来源:time.cpp

示例3: match_orders

            void match_orders( std::vector<signed_transaction>& matched,  asset::type quote, asset::type base )
            { try {
               ilog( "match orders.." );
               auto bids = _market_db.get_bids( quote, base );
               auto asks = _market_db.get_asks( quote, base );
               wlog( "asks: ${asks}", ("asks",asks) );
               wlog( "bids: ${bids}", ("bids",bids) );

               fc::optional<trx_output>  ask_change;
               fc::optional<trx_output>  bid_change;
               fc::optional<trx_output>  cover_change;

               address                   bid_payout_address;
               fc::optional<asset>       bid_payout;

               asset                                cover_collat;       
               fc::optional<claim_by_cover_output>  cover_payout;


               signed_transaction market_trx;
               market_trx.timestamp = fc::time_point::now();


               /** asks are sorted from low to high, so we start
                * with the lowest ask, and check to see if there are
                * any bids that are greaterthan or equal to the ask, if
                * there are then either the full bid or full ask will be
                * filled.  If the full bid is filled, then move on to the
                * next bid, and save the leftover ask.  If the left over
                * ask is filled, then move to the next ask.
                *
                * When there are no more pairs that can be matched, exit
                * the loop and any partial payouts are made.  
                */
               auto ask_itr = asks.begin();
               auto bid_itr = bids.rbegin();
               while( ask_itr != asks.end() &&
                      bid_itr != bids.rend() )
               { 
                  trx_output working_ask;
                  trx_output working_bid;

                  if( ask_change ) {  working_ask = *ask_change; }
                  else             {  working_ask = get_output( ask_itr->location );  }

                  if( bid_change ) {  working_bid = *bid_change; }
                  else             {  working_bid = get_output( bid_itr->location);   }

                  claim_by_bid_output bid_claim = working_bid.as<claim_by_bid_output>();

                  if( working_ask.claim_func == claim_by_long )
                  {
                     auto long_claim = working_ask.as<claim_by_long_output>();
                     if( long_claim.ask_price > bid_claim.ask_price )
                     {
                        break; // exit the while loop, no more trades can occur
                     }
                     asset bid_amount = working_bid.get_amount() * bid_claim.ask_price;
                     asset ask_amount = working_ask.get_amount() * long_claim.ask_price;
                     FC_ASSERT( bid_amount.unit == ask_amount.unit );

                     auto  trade_amount = std::min(bid_amount,ask_amount);

                     ilog( "bid amount: ${b} @ ${bp}  ask amount: ${a} @ ${ap}", ("b",bid_amount)("a",ask_amount)("bp",bid_claim.ask_price)("ap",long_claim.ask_price) );

                     asset bid_change_amount   = working_bid.get_amount();
                     bid_change_amount        -= trade_amount * bid_claim.ask_price;
                     ilog( "bid change.. ${c}", ("c",bid_change_amount) );
                     
                     asset ask_change_amount   = working_ask.get_amount();
                     ask_change_amount        -= trade_amount * long_claim.ask_price;
                     ilog( "ask change.. ${c}", ("c",ask_change_amount) );
                      
                     if( ask_change_amount != bid_change_amount  && ask_change_amount != asset(0,working_bid.unit) )
                     {
                       FC_ASSERT( !"At least one of the bid or ask should be completely filled", "", 
                                  ("ask_change_amount",ask_change_amount)("bid_change_amount",bid_change_amount) );
                     }
                     
                     bid_payout_address = bid_claim.pay_address;
                     auto bid_payout_amount  = bid_amount - (bid_change_amount * bid_claim.ask_price);

                     if( bid_payout ) { *bid_payout += bid_payout_amount; }
                     else             { bid_payout   = bid_payout_amount; }

                     if( cover_payout ) 
                     { 
                        cover_payout->payoff_amount += trade_amount.get_rounded_amount();
                        cover_collat                += (trade_amount * long_claim.ask_price)*2;
                     }
                     else
                     {
                        cover_payout                = claim_by_cover_output();
                        cover_payout->owner         = long_claim.pay_address;
                        cover_payout->payoff_unit   = trade_amount.unit;
                        cover_payout->payoff_amount = trade_amount.get_rounded_amount();
                        cover_collat                = (trade_amount * long_claim.ask_price)*2;
                     }

                     if( bid_change_amount != asset(0, working_bid.unit) )
//.........这里部分代码省略.........
开发者ID:jiefangqian,项目名称:BitShares,代码行数:101,代码来源:blockchain_db.cpp

示例4: FC_ASSERT

void committee_member_create_operation::validate()const
{
   FC_ASSERT( fee.amount >= 0 );
   FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH );
}
开发者ID:0dayZh,项目名称:graphene,代码行数:5,代码来源:committee_member.cpp

示例5: FC_ASSERT

    void domain_buy_operation::evaluate( transaction_evaluation_state& eval_state )
    {
        FC_ASSERT( is_valid_domain( this->domain_name ), "Trying to buy an invalid domain name" );

        auto now = eval_state._current_state->now().sec_since_epoch();
        auto odomain_rec = eval_state._current_state->get_domain_record( this->domain_name );
        /* If it already exists and hasn't expired and you offered enough */
        if( odomain_rec.valid() 
            && odomain_rec->get_true_state(now) == domain_record::in_sale
            && this->price >= odomain_rec->price )
        {
            share_type paid_to_owner = 0;
            for (auto op : eval_state.trx.operations)
            {
                if (op.type == operation_type_enum::deposit_op_type)
                {
                    auto deposit = op.as<deposit_operation>();
                    if (deposit.condition.type == withdraw_condition_types::withdraw_signature_type)
                    {
                        auto condition = deposit.condition.as<withdraw_with_signature>();
                        if (condition.owner == odomain_rec->owner)
                        {
                            paid_to_owner += deposit.amount;
                        }
                    }
                }
            }
            FC_ASSERT( this->price == paid_to_owner );
            FC_ASSERT( paid_to_owner >= odomain_rec->price, "Did not pay enough to previous owner" );
            odomain_rec->state = domain_record::owned;
            odomain_rec->owner = this->new_owner;
            odomain_rec->last_update = eval_state._current_state->now().sec_since_epoch();
            eval_state._current_state->store_domain_record( *odomain_rec );
            return;
        }
        /* Domain does not exist or is not for sale or is too expensive, so this is an offer */
        else
        {
            auto balance = eval_state._current_state->get_domain_offer(this->new_owner);
            FC_ASSERT( !balance.valid(), "Trying to make an offer with an offer ID that already exists");
            FC_ASSERT(this->price > 0, "Price must be greater than 0 when you offer" );
            bool found_deposit = false;
            for ( auto op : eval_state.trx.operations )
            {
                if (op.type == operation_type_enum::deposit_op_type)
                {
                    auto deposit = op.as<deposit_operation>();
                    if( deposit.condition.type == withdraw_condition_types::withdraw_domain_offer_type )
                    {
                        auto condition = deposit.condition.as<bts::blockchain::withdraw_domain_offer>();
                        FC_ASSERT( condition.domain_name == this->domain_name, "condition does not match offer op" );
                        FC_ASSERT( condition.price == this->price, "condition does not match offer op" );
                        FC_ASSERT( condition.owner == this->new_owner, "condition does not match offer op" );
                        found_deposit = true;
                    }
                }
            }
            FC_ASSERT( found_deposit, "Did not find a deposit on this domain offer transaction" );
            auto offer_key = offer_index_key();
            offer_key.price = this->price;
            offer_key.domain_name = this->domain_name;
            offer_key.offer_address = this->new_owner;
            offer_key.offer_time = eval_state._current_state->now().sec_since_epoch();
            ulog( "about to store offer\n" );
            eval_state._current_state->store_domain_offer( offer_key );
        }
    }
开发者ID:tmptest1,项目名称:keyid,代码行数:67,代码来源:dns_operations.cpp

示例6: FC_ASSERT

std::string asset::symbol_name() const {
    auto a = (const char *)&symbol;
    FC_ASSERT(a[7] == 0);
    return &a[1];
}
开发者ID:Rsteem,项目名称:steem,代码行数:5,代码来源:asset.cpp

示例7: FC_ASSERT

 friend bool operator < ( const asset& a, const asset& b )
 {
    FC_ASSERT( a.symbol == b.symbol );
    return std::tie(a.amount,a.symbol) < std::tie(b.amount,b.symbol);
 }
开发者ID:Bitcoinsulting,项目名称:steem,代码行数:5,代码来源:asset.hpp

示例8: as

 WithdrawType as()const
 {
    FC_ASSERT( type == WithdrawType::type, "", ("type",type)("WithdrawType",WithdrawType::type) );
    return fc::raw::unpack<WithdrawType>(data);
 }
开发者ID:HackFisher,项目名称:bitshares_snapshot,代码行数:5,代码来源:withdraw_types.hpp

示例9: FC_ASSERT

 optional<extended_private_key> wallet_db::get_master_key( const fc::sha512& password    )const
 {
    FC_ASSERT( wallet_master_key );
    return wallet_master_key->decrypt_key( password );
 }
开发者ID:371061198,项目名称:bitshares_toolkit,代码行数:5,代码来源:wallet_db.cpp

示例10: validate

 void              validate()const
 {
    FC_ASSERT( fee.amount >= 0 );
    FC_ASSERT( amount.amount > 0 );
 }
开发者ID:0dayZh,项目名称:graphene,代码行数:5,代码来源:vesting.hpp

示例11: as

 OperationType as()const
 {
    FC_ASSERT( (operation_type_enum)type == OperationType::type, "", ("type",type)("OperationType",OperationType::type) );
    return fc::raw::unpack<OperationType>(data);
 }
开发者ID:NewportHighlander,项目名称:PTS,代码行数:5,代码来源:operations.hpp

示例12: validate

 void validate()const { FC_ASSERT( fee.amount >= 0 ); FC_ASSERT(new_listing < 0x4); }
开发者ID:hanxueming126,项目名称:bitshares-core,代码行数:1,代码来源:account.hpp

示例13: FC_ASSERT

price market_order::get_highest_cover_price()const
{ try {
  FC_ASSERT( type == cover_order );
  return asset( state.balance, market_index.order_price.quote_asset_id ) / asset( *collateral );
} FC_CAPTURE_AND_RETHROW() }
开发者ID:abitmore,项目名称:bitshares,代码行数:5,代码来源:market_records.cpp

示例14: FC_ASSERT

 fc::api<network_broadcast_api> login_api::network_broadcast()const
 {
    FC_ASSERT(_network_broadcast_api);
    return *_network_broadcast_api;
 }
开发者ID:wackou,项目名称:graphene,代码行数:5,代码来源:api.cpp

示例15: VERIFY_CORRECT_THREAD

    void message_oriented_connection_impl::read_loop()
    {
      VERIFY_CORRECT_THREAD();
      const unsigned int BUFFER_SIZE = 16;
      static_assert(BUFFER_SIZE >= sizeof(message_header), "insufficient buffer");
      const int LEFTOVER = BUFFER_SIZE - sizeof(message_header);

      _connected_time = fc::time_point::now();

      fc::oexception exception_to_rethrow;
      bool call_on_connection_closed = false;

      try
      {
        message m;
        while( true )
        {
          char buffer[BUFFER_SIZE];
          _sock.read(buffer, BUFFER_SIZE);
          _bytes_received += BUFFER_SIZE;
          memcpy((char*)&m, buffer, sizeof(message_header));

          FC_ASSERT( m.size <= MAX_MESSAGE_SIZE, "", ("m.size",m.size)("MAX_MESSAGE_SIZE",MAX_MESSAGE_SIZE) );

          size_t remaining_bytes_with_padding = 16 * ((m.size - LEFTOVER + 15) / 16);
          m.data.resize(LEFTOVER + remaining_bytes_with_padding); //give extra 16 bytes to allow for padding added in send call
          std::copy(buffer + sizeof(message_header), buffer + sizeof(buffer), m.data.begin());
          if (remaining_bytes_with_padding)
          {
            _sock.read(&m.data[LEFTOVER], remaining_bytes_with_padding);
            _bytes_received += remaining_bytes_with_padding;
          }
          m.data.resize(m.size); // truncate off the padding bytes

          _last_message_received_time = fc::time_point::now();

          try
          {
            // message handling errors are warnings...
            _delegate->on_message(_self, m);
          }
          /// Dedicated catches needed to distinguish from general fc::exception
          catch ( const fc::canceled_exception& e ) { throw e; }
          catch ( const fc::eof_exception& e ) { throw e; }
          catch ( const fc::exception& e)
          {
            /// Here loop should be continued so exception should be just caught locally.
            wlog( "message transmission failed ${er}", ("er", e.to_detail_string() ) );
            throw;
          }
        }
      }
      catch ( const fc::canceled_exception& e )
      {
        wlog( "caught a canceled_exception in read_loop.  this should mean we're in the process of deleting this object already, so there's no need to notify the delegate: ${e}", ("e", e.to_detail_string() ) );
        throw;
      }
      catch ( const fc::eof_exception& e )
      {
        wlog( "disconnected ${e}", ("e", e.to_detail_string() ) );
        call_on_connection_closed = true;
      }
      catch ( const fc::exception& e )
      {
        elog( "disconnected ${er}", ("er", e.to_detail_string() ) );
        call_on_connection_closed = true;
        exception_to_rethrow = fc::unhandled_exception(FC_LOG_MESSAGE(warn, "disconnected: ${e}", ("e", e.to_detail_string())));
      }
      catch ( const std::exception& e )
      {
        elog( "disconnected ${er}", ("er", e.what() ) );
        call_on_connection_closed = true;
        exception_to_rethrow = fc::unhandled_exception(FC_LOG_MESSAGE(warn, "disconnected: ${e}", ("e", e.what())));
      }
      catch ( ... )
      {
        elog( "unexpected exception" );
        call_on_connection_closed = true;
        exception_to_rethrow = fc::unhandled_exception(FC_LOG_MESSAGE(warn, "disconnected: ${e}", ("e", fc::except_str())));
      }

      if (call_on_connection_closed)
        _delegate->on_connection_closed(_self);

      if (exception_to_rethrow)
        throw *exception_to_rethrow;
    }
开发者ID:NewportHighlander,项目名称:PTS,代码行数:87,代码来源:message_oriented_connection.cpp


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