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


C++ FC_THROW_EXCEPTION函数代码示例

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


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

示例1: variant_from_stream

  variant variant_from_stream( T& in, uint32_t max_depth )
  {
     if( max_depth == 0 )
         FC_THROW_EXCEPTION( parse_error_exception, "Too many nested items in JSON input!" );
     skip_white_space(in);
     signed char c = in.peek();
     switch( c )
     {
        case '"':
           return stringFromStream( in );
        case '{':
           return objectFromStream<T, parser_type>( in, max_depth - 1 );
        case '[':
           return arrayFromStream<T, parser_type>( in, max_depth - 1 );
        case '-':
        case '.':
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
           return number_from_stream<T, parser_type>( in );
        // null, true, false, or 'warning' / string
        case 'n':
        case 't':
        case 'f':
           return token_from_stream( in );
        case 0x04: // ^D end of transmission
        case EOF:
           FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" );
        case 0:
           if( parser_type == fc::json::broken_nul_parser )
              return variant();
           FALLTHROUGH
        default:
           FC_THROW_EXCEPTION( parse_error_exception, "Unexpected char '${c}' in \"${s}\"",
                               ("c", c)("s", stringFromToken(in)) );
     }
 }
开发者ID:bitshares,项目名称:fc,代码行数:44,代码来源:json.cpp

示例2: group

//    public_key public_key::mult( const fc::sha256& digest ) const
//    {
//        // get point from this public key
//        const EC_POINT* master_pub   = EC_KEY_get0_public_key( my->_key );
//        ec_group group(EC_GROUP_new_by_curve_name(NID_secp256k1));
//
//        ssl_bignum z;
//        BN_bin2bn((unsigned char*)&digest, sizeof(digest), z);
//
//        // multiply by digest
//        ssl_bignum one;
//        BN_one(one);
//        bn_ctx ctx(BN_CTX_new());
//
//        ec_point result(EC_POINT_new(group));
//        EC_POINT_mul(group, result, z, master_pub, one, ctx);
//
//        public_key rtn;
//        rtn.my->_key = EC_KEY_new_by_curve_name( NID_secp256k1 );
//        EC_KEY_set_public_key(rtn.my->_key,result);
//
//        return rtn;
//    }
    public_key public_key::add( const fc::sha256& digest )const
    {
      try {
        ec_group group(EC_GROUP_new_by_curve_name(NID_secp256k1));
        bn_ctx ctx(BN_CTX_new());

        fc::bigint digest_bi( (char*)&digest, sizeof(digest) );

        ssl_bignum order;
        EC_GROUP_get_order(group, order, ctx);
        if( digest_bi > fc::bigint(order) )
        {
          FC_THROW_EXCEPTION( exception, "digest > group order" );
        }


        public_key digest_key = private_key::regenerate(digest).get_public_key();
        const EC_POINT* digest_point   = EC_KEY_get0_public_key( digest_key.my->_key );

        // get point from this public key
        const EC_POINT* master_pub   = EC_KEY_get0_public_key( my->_key );

//        ssl_bignum z;
//        BN_bin2bn((unsigned char*)&digest, sizeof(digest), z);

        // multiply by digest
//        ssl_bignum one;
//        BN_one(one);

        ec_point result(EC_POINT_new(group));
        EC_POINT_add(group, result, digest_point, master_pub, ctx);

        if (EC_POINT_is_at_infinity(group, result))
        {
          FC_THROW_EXCEPTION( exception, "point at  infinity" );
        }


        public_key rtn;
        rtn.my->_key = EC_KEY_new_by_curve_name( NID_secp256k1 );
        EC_KEY_set_public_key(rtn.my->_key,result);
        return rtn;
      } FC_RETHROW_EXCEPTIONS( debug, "digest: ${digest}", ("digest",digest) );
    }
开发者ID:techsharesteam,项目名称:techshares,代码行数:67,代码来源:elliptic_impl_pub.cpp

示例3: handle_block

      /**
       * @brief allows the application to validate an item prior to broadcasting to peers.
       *
       * @param sync_mode true if the message was fetched through the sync process, false during normal operation
       * @returns true if this message caused the blockchain to switch forks, false if it did not
       *
       * @throws exception if error validating the item, otherwise the item is safe to broadcast on.
       */
      virtual bool handle_block(const graphene::net::block_message& blk_msg, bool sync_mode,
                                std::vector<fc::uint160_t>& contained_transaction_message_ids) override
      { try {

         auto latency = graphene::time::now() - blk_msg.block.timestamp;
         if (!sync_mode || blk_msg.block.block_num() % 10000 == 0)
         {
            const auto& witness = blk_msg.block.witness(*_chain_db);
            const auto& witness_account = witness.witness_account(*_chain_db);
            auto last_irr = _chain_db->get_dynamic_global_properties().last_irreversible_block_num;
            ilog("Got block: #${n} time: ${t} latency: ${l} ms from: ${w}  irreversible: ${i} (-${d})", 
                 ("t",blk_msg.block.timestamp)
                 ("n", blk_msg.block.block_num())
                 ("l", (latency.count()/1000))
                 ("w",witness_account.name)
                 ("i",last_irr)("d",blk_msg.block.block_num()-last_irr) );
         }

         try {
            // TODO: in the case where this block is valid but on a fork that's too old for us to switch to,
            // you can help the network code out by throwing a block_older_than_undo_history exception.
            // when the net code sees that, it will stop trying to push blocks from that chain, but
            // leave that peer connected so that they can get sync blocks from us
            bool result = _chain_db->push_block(blk_msg.block, (_is_block_producer | _force_validate) ? database::skip_nothing : database::skip_transaction_signatures);

            // the block was accepted, so we now know all of the transactions contained in the block
            if (!sync_mode)
            {
               // if we're not in sync mode, there's a chance we will be seeing some transactions
               // included in blocks before we see the free-floating transaction itself.  If that
               // happens, there's no reason to fetch the transactions, so  construct a list of the
               // transaction message ids we no longer need.
               // during sync, it is unlikely that we'll see any old
               for (const processed_transaction& transaction : blk_msg.block.transactions)
               {
                  graphene::net::trx_message transaction_message(transaction);
                  contained_transaction_message_ids.push_back(graphene::net::message(transaction_message).id());
               }
            }

            return result;
         } catch ( const graphene::chain::unlinkable_block_exception& e ) {
            // translate to a graphene::net exception
            elog("Error when pushing block:\n${e}", ("e", e.to_detail_string()));
            FC_THROW_EXCEPTION(graphene::net::unlinkable_block_exception, "Error when pushing block:\n${e}", ("e", e.to_detail_string()));
         } catch( const fc::exception& e ) {
            elog("Error when pushing block:\n${e}", ("e", e.to_detail_string()));
            throw;
         }

         if( !_is_finished_syncing && !sync_mode )
         {
            _is_finished_syncing = true;
            _self->syncing_finished();
         }
      } FC_CAPTURE_AND_RETHROW( (blk_msg)(sync_mode) ) }
开发者ID:unionsharesteam,项目名称:unionshares,代码行数:64,代码来源:application.cpp

示例4: remove

        void remove( const Key& k )
        {
          try
          {
             FC_ASSERT( _db != nullptr );

             std::vector<char> kslice = fc::raw::pack( k );
             ldb::Slice ks( kslice.data(), kslice.size() );
             auto status = _db->Delete( ldb::WriteOptions(), ks );
             if( status.IsNotFound() )
             {
               FC_THROW_EXCEPTION( key_not_found_exception, "unable to find key ${key}", ("key",k) );
             }
             if( !status.ok() )
             {
                 FC_THROW_EXCEPTION( exception, "database error: ${msg}", ("msg", status.ToString() ) );
             }
          } FC_RETHROW_EXCEPTIONS( warn, "error removing ${key}", ("key",k) );
        }
开发者ID:Coinfo,项目名称:bitshares_toolkit,代码行数:19,代码来源:level_map.hpp

示例5: add

 static void add( fc::sha256::encoder &hasher, std::string const &data )
 {
     if( data.size() < 253 ) {
         char len = data.size();
         hasher.write( &len, sizeof(len) );
     } else {
         FC_THROW_EXCEPTION( fc::invalid_arg_exception, "String '" + data + "' too long" );
     }
     hasher.write( data.c_str(), data.size() );
 }
开发者ID:NewportHighlander,项目名称:PTS,代码行数:10,代码来源:pts_address.cpp

示例6: FC_ASSERT

 void private_key::sign( const sha1& digest, array<char,2048/8>& sig )const
 {
    FC_ASSERT( (size_t(RSA_size(my->rsa)) <= sizeof(sig)), "Invalid RSA size" ); 
    uint32_t slen = 0;
    if( 1 != RSA_sign( NID_sha1, (uint8_t*)&digest,
                       20, (unsigned char*)&sig, &slen, my->rsa ) )
    {
        FC_THROW_EXCEPTION( exception, "rsa sign failed with ${message}", ("message",fc::string(ERR_error_string( ERR_get_error(),NULL))) );
    }
 }
开发者ID:FollowMyVote,项目名称:fc,代码行数:10,代码来源:pke.cpp

示例7: if

void client_impl::debug_advance_time(int32_t delta_time, const std::string& unit /* = "seconds" */)
{
   if (unit == "blocks")
      delta_time *= BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC;
   else if (unit == "rounds")
      delta_time *= BTS_BLOCKCHAIN_NUM_DELEGATES * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC;
   else if (unit != "seconds")
      FC_THROW_EXCEPTION(fc::invalid_arg_exception, "unit must be \"seconds\", \"blocks\", or \"rounds\", was: \"${unit}\"", ("unit", unit));
   bts::blockchain::advance_time(delta_time);
}
开发者ID:NewportHighlander,项目名称:PTS,代码行数:10,代码来源:debug_api.cpp

示例8: import_electrum_wallet

 std::vector<fc::ecc::private_key> import_electrum_wallet( const fc::path& wallet_dat, const std::string& passphrase )
 { try {
     std::vector<fc::ecc::private_key> keys;
     electrumwallet wallet( wallet_dat.to_native_ansi_path());
     if( !wallet.ok() ) FC_THROW_EXCEPTION( exception, "invalid electrum wallet");
     wallet.derivekeys( passphrase );
     return wallet.keys();
   }
   FC_RETHROW_EXCEPTIONS( warn, "" )
 }
开发者ID:BrownBear2,项目名称:BitShares,代码行数:10,代码来源:electrum_wallet.cpp

示例9: null_terminated_ptr_impl

/**
 * class to represent an in-wasm-memory char array that must be null terminated
 */
inline null_terminated_ptr null_terminated_ptr_impl(interpreter_interface* interface, uint32_t ptr)
{
   char *value = interface->get_validated_pointer(ptr, 1);
   const char* p = value;
   const char* const top_of_memory = interface->memory.data + interface->current_memory_size;
   while(p < top_of_memory)
      if(*p++ == '\0')
         return null_terminated_ptr(value);

   FC_THROW_EXCEPTION(wasm_execution_error, "unterminated string");
}
开发者ID:milk57618,项目名称:eos,代码行数:14,代码来源:binaryen.hpp

示例10: begin

        iterator begin() 
        { try {
           iterator itr( _db->NewIterator( ldb::ReadOptions() ) );
           itr._it->SeekToFirst();

           if( itr._it->status().IsNotFound() )
           {
             FC_THROW_EXCEPTION( key_not_found_exception, "" );
           }
           if( !itr._it->status().ok() )
           {
               FC_THROW_EXCEPTION( exception, "database error: ${msg}", ("msg", itr._it->status().ToString() ) );
           }

           if( itr.valid() )
           {
              return itr;
           }
           return iterator();
        } FC_RETHROW_EXCEPTIONS( warn, "error seeking to first" ) }
开发者ID:BrownBear2,项目名称:BitShares,代码行数:20,代码来源:level_map.hpp

示例11: memcpy

   pts_address::pts_address( const std::string& base58str )
   {
      std::vector<char> v = fc::from_base58( fc::string(base58str) );
      if( v.size() )
         memcpy( addr.data, v.data(), std::min<size_t>( v.size(), sizeof(addr) ) );

      if( !is_valid() )
      {
         FC_THROW_EXCEPTION( exception, "invalid pts_address ${a}", ("a", base58str) );  
      }
   }
开发者ID:NimroDeer,项目名称:BitShares,代码行数:11,代码来源:pts_address.cpp

示例12: fetch

 Value fetch( const Key& key )
 {
   try {
      ldb::Slice key_slice( (char*)&key, sizeof(key) );
      std::string value;
      auto status = _db->Get( ldb::ReadOptions(), key_slice, &value );
      if( status.IsNotFound() )
      {
        FC_THROW_EXCEPTION( key_not_found_exception, "unable to find key ${key}", ("key",key) );
      }
      if( !status.ok() )
      {
          FC_THROW_EXCEPTION( exception, "database error: ${msg}", ("msg", status.ToString() ) );
      }
      fc::datastream<const char*> datastream(value.c_str(), value.size());
      Value tmp;
      fc::raw::unpack(datastream, tmp);
      return tmp;
   } FC_RETHROW_EXCEPTIONS( warn, "error fetching key ${key}", ("key",key) );
 }
开发者ID:Doken-Tokuyama,项目名称:BitShares,代码行数:20,代码来源:level_pod_map.hpp

示例13: fetch

        Value fetch( const Key& key )
        { try {
           FC_ASSERT( is_open(), "Database is not open!" );

           ldb::Slice key_slice( (char*)&key, sizeof(key) );
           std::string value;
           auto status = _db->Get( _read_options, key_slice, &value );
           if( status.IsNotFound() )
           {
             FC_THROW_EXCEPTION( fc::key_not_found_exception, "unable to find key ${key}", ("key",key) );
           }
           if( !status.ok() )
           {
               FC_THROW_EXCEPTION( level_pod_map_failure, "database error: ${msg}", ("msg", status.ToString() ) );
           }
           fc::datastream<const char*> datastream(value.c_str(), value.size());
           Value tmp;
           fc::raw::unpack(datastream, tmp);
           return tmp;
        } FC_RETHROW_EXCEPTIONS( warn, "error fetching key ${key}", ("key",key) ); }
开发者ID:ElleryHao,项目名称:Goopal,代码行数:20,代码来源:LevelPodMap.hpp

示例14: fetch

        Value fetch( const Key& k )
        { try {
           FC_ASSERT( is_open(), "Database is not open!" );

           std::vector<char> kslice = fc::raw::pack( k );
           ldb::Slice ks( kslice.data(), kslice.size() );
           std::string value;
           auto status = _db->Get( ldb::ReadOptions(), ks, &value );
           if( status.IsNotFound() )
           {
             FC_THROW_EXCEPTION( fc::key_not_found_exception, "unable to find key ${key}", ("key",k) );
           }
           if( !status.ok() )
           {
               FC_THROW_EXCEPTION( db_exception, "database error: ${msg}", ("msg", status.ToString() ) );
           }
           fc::datastream<const char*> ds(value.c_str(), value.size());
           Value tmp;
           fc::raw::unpack(ds, tmp);
           return tmp;
        } FC_RETHROW_EXCEPTIONS( warn, "error fetching key ${key}", ("key",k) ); }
开发者ID:andrewisplinghoff,项目名称:bitsharesx,代码行数:21,代码来源:level_map.hpp

示例15: FC_ASSERT

 asset& asset::operator -= ( const asset& o )
 {
    FC_ASSERT( asset_id == o.asset_id );
    auto old = *this;;
    amount -= o.amount;
    if( amount > old.amount ) 
    {
       FC_THROW_EXCEPTION( addition_underthrow, "asset addition underflow  ${a} - ${b} = ${c}", 
                           ("a", old)("b",o)("c",*this) );
    }
    return *this;
 }
开发者ID:HackFisher,项目名称:bitshares_snapshot,代码行数:12,代码来源:asset.cpp


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