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

C++ code类代码示例

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

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



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

示例1: inbound_channel_stopped

void protocol::inbound_channel_stopped(const code& ec,
    channel::ptr node, const std::string& address)
{
    log_debug(LOG_PROTOCOL)
        << "Channel stopped (inbound) [" << address << "] "
        << ec.message();

    // We never attempt to reconnect inbound connections.
    remove_connection(inbound_connections_, node);
}
开发者ID:cissp0,项目名称:libbitcoin,代码行数:10,代码来源:protocol.cpp


示例2: size

// new blocks come in - remove txs in new
// old blocks taken out - resubmit txs in old
bool transaction_pool::handle_reorganized(const code& ec, size_t fork_point,
    const block::ptr_list& new_blocks, const block::ptr_list& replaced_blocks)
{
    if (ec == error::service_stopped)
    {
        log::debug(LOG_BLOCKCHAIN)
            << "Stopping transaction pool: " << ec.message();
        return false;
    }

    if (ec)
    {
        log::debug(LOG_BLOCKCHAIN)
            << "Failure in tx pool reorganize handler: " << ec.message();
        return false;
    }

    log::debug(LOG_BLOCKCHAIN)
        << "Reorganize: tx pool size (" << buffer_.size()
        << ") forked at (" << fork_point
        << ") new blocks (" << new_blocks.size()
        << ") replace blocks (" << replaced_blocks.size() << ")";

    if (replaced_blocks.empty())
    {
        // Remove memory pool transactions that also exist in new blocks.
        dispatch_.ordered(
            std::bind(&transaction_pool::remove,
                this, new_blocks));
    }
    else
    {
        // See http://www.jwz.org/doc/worse-is-better.html
        // for why we take this approach. We return with an error_code.
        // An alternative would be resubmit all tx from the cleared blocks.
        dispatch_.ordered(
            std::bind(&transaction_pool::clear,
                this, error::blockchain_reorganized));
    }

    return true;
}
开发者ID:jasonw580,项目名称:libbitcoin-blockchain,代码行数:44,代码来源:transaction_pool.cpp


示例3: handle_channel_stop

void session_manual::handle_channel_stop(const code& ec,
    const std::string& hostname, uint16_t port)
{
    LOG_DEBUG(LOG_NETWORK)
        << "Manual channel stopped: " << ec.message();

    // Special case for already connected, do not keep trying.
    // After a stop we don't use the caller's start handler, but keep connecting.
    if (ec != error::address_in_use)
        connect(hostname, port);
}
开发者ID:thecodefactory,项目名称:libbitcoin-network,代码行数:11,代码来源:session_manual.cpp


示例4: handle_timer

void protocol_base_base::handle_timer(const code& ec)
{
    if (stopped() || deadline::canceled(ec))
        return;

    log_debug(LOG_PROTOCOL)
        << "Fired " << name_ << " protocol timer on [" << authority() << "] "
        << ec.message();

    callback(error::channel_timeout);
}
开发者ID:stealthylabs,项目名称:libbitcoin,代码行数:11,代码来源:protocol_base_base.cpp


示例5: succeeded

bool callback_state::succeeded(const code& ec, const std::string& format)
{
    if (ec)
    {
        // May want to change the behavior to decrement vs. zeroizing refs.
        error(boost::format(format) % ec.message());
        stop(console_result::failure);
        return false;
    }

    return true;
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:12,代码来源:callback_state.cpp


示例6: handle_store_addresses

void protocol_address::handle_store_addresses(const code& ec)
{
    if (stopped())
        return;

    if (ec)
    {
        log_error(LOG_PROTOCOL)
            << "Failure storing addresses from [" << authority() << "] "
            << ec.message();
        stop(ec);
    }
}
开发者ID:ballisticwhisper,项目名称:libbitcoin,代码行数:13,代码来源:protocol_address.cpp


示例7: handle_send_get_address

void protocol_address::handle_send_get_address(const code& ec)
{
    if (stopped())
        return;

    if (ec)
    {
        log_debug(LOG_PROTOCOL)
            << "Failure sending get_address [" << authority() << "] "
            << ec.message();
        stop(ec);
    }
}
开发者ID:ballisticwhisper,项目名称:libbitcoin,代码行数:13,代码来源:protocol_address.cpp


示例8: checkIncorrect

//  input:
//      code guess - a code object containing the user's guess
//  output:
//      int incorrect - the number of digits in the guess that exist in the secret, but are not correctly placed
//
//  Check how many digits are part of the secret code, but were guessed at wrong positions. If an index is set to 6
//  we know that the index has been covered and will skip it. If an element in the same spot in secretDigits is set to 6,
//  this also means that the value has been covered.
//  ASSUMPTION: This is called AFTER checkIncorrect so that it will only check indices that haven't been confirmed
int code::checkIncorrect(code guess) {
    vector<int> userGuess = guess.getGuess();
    vector<int> secretCode = guess.getSecret();
    vector<int> secretDigits = getDigits();

    int incorrect = 0;
    for (int i=0; i < userGuess.size(); i++) {
        //Index has already been confirmed, move on
        if (userGuess[i] == 6) {
            continue;
        }
        //Digit IS part of solution, HAS NOT been verified by checkCorrect, but in wrong place
        if (find(secretDigits.begin(), secretDigits.end(), userGuess[i]) != secretDigits.end() && userGuess[i] != secretDigits[i] && secretDigits[i] != 6) {
            incorrect += 1;
            userGuess[i] = 6;
            secretDigits[distance( secretDigits.begin(), find(secretDigits.begin(), secretDigits.end(), userGuess[i]))] = 6;
        }
    }

    setDigits(secretDigits);
    return incorrect;
}
开发者ID:eric-cc-su,项目名称:CodeBits,代码行数:31,代码来源:code.cpp


示例9: handle_channel_start

void session_inbound::handle_channel_start(const code& ec,
    channel::ptr channel)
{
    if (ec)
    {
        LOG_INFO(LOG_NETWORK)
            << "Inbound channel failed to start [" << channel->authority()
            << "] " << ec.message();
        return;
    }

    attach_protocols(channel);
};
开发者ID:libbitcoin,项目名称:libbitcoin-network,代码行数:13,代码来源:session_inbound.cpp


示例10: outbound_channel_stopped

void protocol::outbound_channel_stopped(const code& ec,
    channel::ptr node, const std::string& address)
{
    log_debug(LOG_PROTOCOL)
        << "Channel stopped (outbound) [" << address << "] "
        << ec.message();

    remove_connection(outbound_connections_, node);

    // If not shutdown we always create a replacement oubound connection.
    if (ec != error::service_stopped)
        new_connection();
}
开发者ID:cissp0,项目名称:libbitcoin,代码行数:13,代码来源:protocol.cpp


示例11: handler

void p2p::handle_running(const code& ec, result_handler handler)
{
    if (ec)
    {
        LOG_ERROR(LOG_NETWORK)
            << "Error starting outbound session: " << ec.message();
        handler(ec);
        return;
    }

    // This is the end of the run sequence.
    handler(error::success);
}
开发者ID:thecodefactory,项目名称:libbitcoin-network,代码行数:13,代码来源:p2p.cpp


示例12: manual_channel_stopped

void protocol::manual_channel_stopped(const code& ec,
    channel::ptr node, const std::string& address, bool relay, size_t retries)
{
    log_debug(LOG_PROTOCOL)
        << "Channel stopped (manual) [" << address << "] "
        << ec.message();

    remove_connection(manual_connections_, node);

    // If not shutdown we always attempt to reconnect manual connections.
    if (ec != error::service_stopped)
        retry_manual_connection(address, relay, retries);
}
开发者ID:cissp0,项目名称:libbitcoin,代码行数:13,代码来源:protocol.cpp


示例13: handle_send_pong

void protocol_ping::handle_send_pong(const code& ec)
{
    if (stopped())
        return;

    if (ec)
    {
        log::debug(LOG_NETWORK)
            << "Failure sending pong to [" << authority() << "] "
            << ec.message();
        stop(ec);
    }
}
开发者ID:staring,项目名称:libbitcoin-network,代码行数:13,代码来源:protocol_ping.cpp


示例14: handle_send

void protocol_header_sync::handle_send(const code& ec, event_handler complete)
{
    if (stopped())
        return;

    if (ec)
    {
        log::debug(LOG_PROTOCOL)
            << "Failure sending get headers to sync [" << authority() << "] "
            << ec.message();
        complete(ec);
    }
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-node,代码行数:13,代码来源:protocol_header_sync.cpp


示例15: authority

void protocol_version_31402::handle_verack_sent(const code& ec)
{
    if (stopped())
        return;

    if (ec)
    {
        LOG_DEBUG(LOG_NETWORK)
            << "Failure sending verack to [" << authority() << "] "
            << ec.message();
        set_event(ec);
        return;
    }
}
开发者ID:libbitcoin,项目名称:libbitcoin-network,代码行数:14,代码来源:protocol_version_31402.cpp


示例16: handle_receive

bool protocol_header_sync::handle_receive(const code& ec, headers::ptr message,
    event_handler complete)
{
    if (stopped())
        return false;

    if (ec)
    {
        log::debug(LOG_PROTOCOL)
            << "Failure receiving headers from sync ["
            << authority() << "] " << ec.message();
        complete(ec);
        return false;
    }

    // A merge failure includes automatic rollback to last trust point.
    if (!hashes_.enqueue(message))
    {
        log::warning(LOG_PROTOCOL)
            << "Failure merging headers from [" << authority() << "]";
        complete(error::previous_block_invalid);
        return false;
    }

    const auto next = next_height();

    log::info(LOG_PROTOCOL)
        << "Synced headers " << next - message->elements.size()
        << "-" << (next - 1) << " from [" << authority() << "]";


    // If we reached the last height the sync is complete/success.
    if (next > final_height_)
    {
        complete(error::success);
        return false;
    }

    // If we received fewer than 2000 the peer is exhausted, try another.
    if (message->elements.size() < max_header_response)
    {
        complete(error::operation_failed);
        return false;
    }

    // This peer has more headers.
    send_get_headers(complete);
    return true;
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-node,代码行数:49,代码来源:protocol_header_sync.cpp


示例17: handle_accept

void protocol::handle_accept(const code& ec, channel::ptr node,
    acceptor::ptr accept)
{
    // Relisten for connections.
    start_accept(ec, accept);

    if (ec)
    {
        log_debug(LOG_PROTOCOL)
            << "Failure accepting connection: " << ec.message();
        return;
    }

    if (inbound_connections_.size() >= max_inbound_)
    {
        log_debug(LOG_PROTOCOL)
            << "Rejected inbound connection due to connection limit";
        return;
    }

    const auto address = node->address();
    if (is_blacklisted(node->address()))
    {
        log_debug(LOG_PROTOCOL)
            << "Rejected inbound connection due to blacklisted address";
        return;
    }

    if (is_loopback(node))
    {
        log_debug(LOG_PROTOCOL)
            << "Rejected inbound connection from self";
        return;
    }

    // Save the connection as we are now assured of getting stop event.
    inbound_connections_.push_back(node);

    // Accepted!
    log_info(LOG_PROTOCOL)
        << "Accepted connection from [" << address << "] ("
        << inbound_connections_.size() << " total)";

    const auto stop_handler = 
        dispatch_.ordered_delegate(&protocol::inbound_channel_stopped,
            this, _1, node, address.to_string());

    start_talking(node, stop_handler, relay_);
}
开发者ID:cissp0,项目名称:libbitcoin,代码行数:49,代码来源:protocol.cpp


示例18: handle_stop

void protocol_base_base::handle_stop(const code& ec)
{
    if (stopped())
        return;

    log_debug(LOG_PROTOCOL)
        << "Stopped " << name_ << " protocol on [" << authority() << "] "
        << ec.message();

    stopped_ = true;
    if (deadline_)
        deadline_->cancel();

    callback(ec);
}
开发者ID:stealthylabs,项目名称:libbitcoin,代码行数:15,代码来源:protocol_base_base.cpp


示例19: handle_starting

void session::handle_starting(const code& ec, channel::ptr channel,
    result_handler handle_started)
{
    if (ec)
    {
        LOG_INFO(LOG_NETWORK)
            << "Channel failed to start [" << channel->authority() << "] "
            << ec.message();
        handle_started(ec);
        return;
    }

    attach_handshake_protocols(channel,
        BIND_3(handle_handshake, _1, channel, handle_started));
}
开发者ID:libbitcoin,项目名称:libbitcoin-network,代码行数:15,代码来源:session.cpp


示例20: rangeError

int operator%(const code &lhs, const vector<int> &rhs)
// Overloaded operator that returns the number of digits in the code
// in the lhs that match the vector rhs.
{
   int count = 0;
   
   if (lhs.size() != rhs.size())
      throw rangeError();

   for (int i = 0; i < rhs.size(); i++)
      if (lhs.seq[i] == rhs[i])
	 count++;

   return count;
}
开发者ID:tLiMiT,项目名称:EECE-3326,代码行数:15,代码来源:quiz2s.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ codeGen类代码示例发布时间:2022-05-31
下一篇:
C++ cmd_context类代码示例发布时间: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