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

C++ channel::ptr类代码示例

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

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



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

示例1: send_pool_tx

void responder::send_pool_tx(const code& ec, const transaction& tx,
    const hash_digest& tx_hash, channel::ptr node)
{
    if (ec == error::service_stopped)
        return;

    if (ec == error::not_found)
    {
        log::debug(LOG_RESPONDER)
            << "Transaction for [" << node->authority()
            << "] not in mempool [" << encode_hash(tx_hash) << "]";

        // It wasn't in the mempool, so relay the request to the blockchain.
        blockchain_.fetch_transaction(tx_hash,
            std::bind(&responder::send_chain_tx,
                this, _1, _2, tx_hash, node));
        return;
    }

    if (ec)
    {
        log::error(LOG_RESPONDER)
            << "Failure fetching mempool tx data for ["
            << node->authority() << "] " << ec.message();
        node->stop(ec);
        return;
    }

    send_tx(tx, tx_hash, node);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:30,代码来源:responder.cpp


示例2: handle_is_pending

void session::handle_is_pending(bool pending, channel::ptr channel,
    result_handler handle_started)
{
    if (pending)
    {
        log::debug(LOG_NETWORK)
            << "Rejected connection from [" << channel->authority()
            << "] as loopback.";
        handle_started(error::accept_failed);
        return;
    }

    const auto version = channel->version();
    if (version.value < bc::peer_minimum_version)
    {
        log::debug(LOG_NETWORK)
            << "Peer version (" << version.value << ") below minimum ("
            << bc::peer_minimum_version << ") [" 
            << channel->authority() << "]";
        handle_started(error::accept_failed);
        return;
    }

    network_.store(channel, handle_started);
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-network,代码行数:25,代码来源:session.cpp


示例3: register_channel

// protected:
void session::register_channel(channel::ptr channel,
    result_handler handle_started, result_handler handle_stopped)
{
    result_handler stop_handler =
        BIND_3(do_remove, _1, channel, handle_stopped);

    result_handler start_handler =
        BIND_4(handle_start, _1, channel, handle_started, stop_handler);

    if (stopped())
    {
        start_handler(error::service_stopped);
        return;
    }

    if (incoming_)
    {
        handle_pend(error::success, channel, start_handler);
        return;
    }

    channel->set_notify(notify_);
    channel->set_nonce(nonzero_pseudo_random());

    result_handler unpend_handler =
        BIND_3(do_unpend, _1, channel, start_handler);

    pending_.store(channel,
        BIND_3(handle_pend, _1, channel, unpend_handler));
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-network,代码行数:31,代码来源:session.cpp


示例4: send_chain_tx

// en.bitcoin.it/wiki/Protocol_documentation#getdata
// getdata can be used to retrieve transactions, but only if they are
// in the memory pool or relay set - arbitrary access to transactions
// in the  chain is not allowed to avoid having clients start to depend
// on nodes having full transaction indexes (which modern nodes do not).
void responder::send_chain_tx(const code& ec, const transaction& tx,
    const hash_digest& tx_hash, channel::ptr node)
{
    if (ec == error::service_stopped)
        return;

    if (ec == error::not_found)
    {
        log::debug(LOG_RESPONDER)
            << "Transaction for [" << node->authority()
            << "] not in blockchain [" << encode_hash(tx_hash) << "]";

        // It wasn't in the blockchain, so send notfound.
        send_tx_not_found(tx_hash, node);
        return;
    }

    if (ec)
    {
        log::error(LOG_RESPONDER)
            << "Failure fetching blockchain tx data for ["
            << node->authority() << "] " << ec.message();
        node->stop(ec);
        return;
    }

    send_tx(tx, tx_hash, node);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:33,代码来源:responder.cpp


示例5: receive_get_data

// We don't seem to be getting getdata requests.
void responder::receive_get_data(const code& ec, const get_data& packet,
    channel::ptr node)
{
    if (ec == error::channel_stopped)
        return;

    const auto peer = node->authority();

    if (ec)
    {
        log::debug(LOG_RESPONDER)
            << "Failure in receive get data [" << peer << "] " << ec.message();
        node->stop(ec);
        return;
    }

    // Resubscribe to serve tx and blocks.
    node->subscribe<message::get_data>(
        std::bind(&responder::receive_get_data,
            this, _1, _2, node));

    log::debug(LOG_RESPONDER)
        << "Getdata BEGIN [" << peer << "] "
        << "txs (" << packet.count(inventory_type_id::transaction) << ") "
        << "blocks (" << packet.count(inventory_type_id::block) << ") "
        << "bloom (" << packet.count(inventory_type_id::filtered_block) << ")";

    for (const auto& inventory: packet.inventories)
    {
        switch (inventory.type)
        {
            case inventory_type_id::transaction:
                log::debug(LOG_RESPONDER)
                    << "Transaction getdata for [" << peer << "] "
                    << encode_hash(inventory.hash);
                tx_pool_.fetch(inventory.hash,
                    std::bind(&responder::send_pool_tx,
                        this, _1, _2, inventory.hash, node));
                break;

            case inventory_type_id::block:
                log::debug(LOG_RESPONDER)
                    << "Block getdata for [" << peer << "] "
                    << encode_hash(inventory.hash);
                block_fetcher::fetch(blockchain_, inventory.hash,
                    std::bind(&responder::send_block,
                        this, _1, _2, inventory.hash, node));
                break;

            case inventory_type_id::error:
            case inventory_type_id::none:
            default:
                log::debug(LOG_RESPONDER)
                    << "Ignoring invalid getdata type for [" << peer << "]";
        }
    }

    log::debug(LOG_RESPONDER)
        << "Getdata END [" << peer << "]";
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:61,代码来源:responder.cpp


示例6: handle_accept

void session_inbound::handle_accept(const code& ec, channel::ptr channel,
    acceptor::ptr accept)
{
    if (stopped())
        return;

    start_accept(error::success, accept);

    if (ec)
    {
        log::debug(LOG_NETWORK)
            << "Failure accepting connection: " << ec.message();
        return;
    }

    if (blacklisted(channel->authority()))
    {
        log::debug(LOG_NETWORK)
            << "Rejected inbound connection from ["
            << channel->authority() << "] due to blacklisted address.";
        return;
    }

    connection_count(
        dispatch_.ordered_delegate(&session_inbound::handle_connection_count,
            shared_from_base<session_inbound>(), _1, channel));
}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:27,代码来源:session_inbound.cpp


示例7: handle_accept

void session_inbound::handle_accept(const code& ec, channel::ptr channel,
    acceptor::ptr accept)
{
    if (stopped())
    {
        log::debug(LOG_NETWORK)
            << "Suspended inbound connection.";
        return;
    }

    start_accept(error::success, accept);

    if (ec)
    {
        log::debug(LOG_NETWORK)
            << "Failure accepting connection: " << ec.message();
        return;
    }

    if (blacklisted(channel->authority()))
    {
        log::debug(LOG_NETWORK)
            << "Rejected inbound connection from ["
            << channel->authority() << "] due to blacklisted address.";
        return;
    }

    connection_count(BIND2(handle_connection_count, _1, channel));
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-network,代码行数:29,代码来源:session_inbound.cpp


示例8: start_channel

// protected:
void session::start_channel(channel::ptr channel,
    result_handler handle_started)
{
    channel->set_notify(notify_on_connect_);
    channel->set_nonce(pseudo_random(1, max_uint64));

    // The channel starts, invokes the handler, then starts the read cycle.
    channel->start(
        BIND_3(handle_starting, _1, channel, handle_started));
}
开发者ID:libbitcoin,项目名称:libbitcoin-network,代码行数:11,代码来源:session.cpp


示例9: handle_start

void session::handle_start(const code& ec, channel::ptr channel,
    result_handler handle_started, result_handler handle_stopped)
{
    // Must either stop or subscribe the channel for stop before returning.
    if (ec)
        channel->stop(ec);
    else
        channel->subscribe_stop(handle_stopped);

    // This is the end of the registration sequence.
    handle_started(ec);
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-network,代码行数:12,代码来源:session.cpp


示例10: 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


示例11: handle_connect

void session_manual::handle_connect(const code& ec, channel::ptr channel,
    const std::string& hostname, uint16_t port, uint32_t remaining,
    connector::ptr connector, channel_handler handler)
{
    unpend(connector);

    if (ec)
    {
        LOG_WARNING(LOG_NETWORK)
            << "Failure connecting [" << config::endpoint(hostname, port)
            << "] manually: " << ec.message();

        // Retry logic.
        // The handler invoke is the failure end of the connect sequence.
        if (settings_.manual_attempt_limit == 0)
            start_connect(hostname, port, 0, handler);
        else if (remaining > 0)
            start_connect(hostname, port, remaining - 1, handler);
        else
            handler(ec, nullptr);

        return;
    }

    LOG_INFO(LOG_NETWORK)
        << "Connected manual channel [" << config::endpoint(hostname, port)
        << "] as [" << channel->authority() << "]";

    register_channel(channel, 
        BIND5(handle_channel_start, _1, hostname, port, channel, handler),
        BIND3(handle_channel_stop, _1, hostname, port));
}
开发者ID:thecodefactory,项目名称:libbitcoin-network,代码行数:32,代码来源:session_manual.cpp


示例12: handle_handshake

void protocol::handle_handshake(const code& ec, channel::ptr node)
{
    if (ec)
    {
        log_debug(LOG_PROTOCOL) << "Failure in peer handshake ["
            << node->address() << "] " << ec.message();
        node->stop(ec);
        return;
    }

    // Attach ping protocol to the new connection (until node stop event).
    std::make_shared<protocol_ping>(node, pool_, timeouts_.heartbeat)->start();

    // Attach address protocol to the new connection (until node stop event).
    std::make_shared<protocol_address>(node, pool_, hosts_, self_)->start();
}
开发者ID:cissp0,项目名称:libbitcoin,代码行数:16,代码来源:protocol.cpp


示例13: safe_store

bool pending_channels::safe_store(channel::ptr channel)
{
    const auto version_nonce = channel->nonce();
    const auto match = [version_nonce](const channel::ptr& entry)
    {
        return entry->nonce() == version_nonce;
    };

    // Critical Section
    ///////////////////////////////////////////////////////////////////////////
    mutex_.lock_upgrade();

    const auto it = std::find_if(channels_.begin(), channels_.end(), match);
    const auto found = it != channels_.end();

    if (!found)
    {
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        mutex_.unlock_upgrade_and_lock();
        channels_.push_back(channel);
        mutex_.unlock();
        //---------------------------------------------------------------------
        return true;
    }

    mutex_.unlock_upgrade();
    ///////////////////////////////////////////////////////////////////////////

    return false;
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-network,代码行数:30,代码来源:pending_channels.cpp


示例14: do_unpend

void session::do_unpend(const code& ec, channel::ptr channel,
    result_handler handle_started)
{
    channel->set_nonce(0);
    pending_.remove(channel, BIND_1(handle_unpend, _1));
    handle_started(ec);
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-network,代码行数:7,代码来源:session.cpp


示例15: handle_remove

void session::handle_remove(const code& ec, channel::ptr channel)
{
    if (ec)
        LOG_DEBUG(LOG_NETWORK)
            << "Failed to remove channel [" << channel->authority() << "] "
            << ec.message();
}
开发者ID:libbitcoin,项目名称:libbitcoin-network,代码行数:7,代码来源:session.cpp


示例16:

code p2p::store(channel::ptr channel)
{
    const auto address = channel->authority();
    const auto match = [&address](const channel::ptr& element)
    {
        return element->authority() == address;
    };

    // May return error::address_in_use.
    const auto ec = pending_close_.store(channel, match);

    if (!ec && channel->notify())
        channel_subscriber_->relay(error::success, channel);

    return ec;
}
开发者ID:thecodefactory,项目名称:libbitcoin-network,代码行数:16,代码来源:p2p.cpp


示例17: handle_connect

void session_manual::handle_connect(const code& ec, channel::ptr channel,
    const std::string& hostname, uint16_t port, channel_handler handler,
    uint16_t retries)
{
    if (ec)
    {
        log::warning(LOG_NETWORK)
            << "Failure connecting [" << config::endpoint(hostname, port)
            << "] manually: " << ec.message();

        // Retry logic.
        if (settings_.connect_attempts == 0)
            start_connect(hostname, port, handler, 0);
        else if (retries > 0)
            start_connect(hostname, port, handler, retries - 1);
        else
            handler(ec, nullptr);

        return;
    }

    log::info(LOG_NETWORK)
        << "Connected manual channel [" << config::endpoint(hostname, port)
        << "] as [" << channel->authority() << "]";

    register_channel(channel, 
        std::bind(&session_manual::handle_channel_start,
            shared_from_base<session_manual>(), _1, hostname, port, channel, handler),
        std::bind(&session_manual::handle_channel_stop,
            shared_from_base<session_manual>(), _1, hostname, port));
}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:31,代码来源:session_manual.cpp


示例18: send_tx_not_found

void responder::send_tx_not_found(const hash_digest& hash, channel::ptr node)
{
    const auto send_handler = [hash, node](const code& ec)
    {
        if (ec)
            log::debug(LOG_RESPONDER)
                << "Failure sending tx notfound for ["
                << node->authority() << "]";
        else
            log::debug(LOG_RESPONDER)
                << "Sent tx notfound for [" << node->authority()
                << "] " << encode_hash(hash);
    };

    send_inventory_not_found(inventory_type_id::transaction, hash, node,
        send_handler);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:17,代码来源:responder.cpp


示例19: send_tx

void responder::send_tx(const transaction& tx, const hash_digest& hash,
    channel::ptr node)
{
    const auto send_handler = [hash, node](const code& ec)
    {
        if (ec)
            log::debug(LOG_RESPONDER)
                << "Failure sending tx for ["
                << node->authority() << "]";
        else
            log::debug(LOG_RESPONDER)
                << "Sent tx for [" << node->authority()
                << "] " << encode_hash(hash);
    };

    node->send(tx, send_handler);
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:17,代码来源:responder.cpp


示例20: attach_protocols

void session_manual::attach_protocols(channel::ptr channel)
{
    if (channel->negotiated_version() >= message::version::level::bip31)
        attach<protocol_ping_60001>(channel)->start();
    else
        attach<protocol_ping_31402>(channel)->start();

    attach<protocol_address_31402>(channel)->start();
}
开发者ID:thecodefactory,项目名称:libbitcoin-network,代码行数:9,代码来源:session_manual.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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