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


C++ channel_ptr类代码示例

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


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

示例1: receive_version

		void handshake::receive_version(
			const std::error_code& ec, const version_type&,
			channel_ptr node, handshake::handshake_handler completion_callback)
		{
			if (ec)
				completion_callback(ec);
			else
				node->send(verack_type(),
				strand_.wrap(std::bind(&handshake::handle_message_sent,
				this, _1, completion_callback)));
		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:11,代码来源:handshake.cpp

示例2:

void protocol::seeds::request_addresses(
    const std::error_code& ec, channel_ptr dns_seed_node)
{
    if (ec)
    {
        log_error(LOG_PROTOCOL)
            << "Failed to connect to seed node: " << ec.message();
        error_case(ec);
    }
    else
    {
        dns_seed_node->send(get_address_type(),
            strand_.wrap(std::bind(&protocol::seeds::handle_send_get_address,
                shared_from_this(), _1)));
        dns_seed_node->subscribe_address(
            strand_.wrap(std::bind(&protocol::seeds::save_addresses,
                shared_from_this(), _1, _2, dns_seed_node)));
    }

}
开发者ID:genba,项目名称:libbitcoin,代码行数:20,代码来源:protocol.cpp

示例3: recv_transaction

void recv_transaction(const std::error_code& ec,
    const transaction_type& tx, channel_ptr node)
{
    if (ec)
    {
        log_error() << "transaction: " << ec.message();
        return;
    }
    p->transaction_pool_.store(tx, handle_confirm,
        std::bind(&handle_mempool_store, _1, _2, tx, node));
    node->subscribe_transaction(std::bind(recv_transaction, _1, _2, node));
}
开发者ID:bitkevin,项目名称:libbitcoin,代码行数:12,代码来源:sesh.cpp

示例4: monitor_tx

void node_impl::monitor_tx(const std::error_code& ec, channel_ptr node)
{
    if (ec)
    {
        log_warning() << "Couldn't start connection: " << ec.message();
        return;
    }
    node->subscribe_transaction(
        std::bind(&node_impl::recv_transaction, this, _1, _2, node));
    protocol_.subscribe_channel(
        std::bind(&node_impl::monitor_tx, this, _1, _2));
}
开发者ID:litecoin-extras,项目名称:obelisk,代码行数:12,代码来源:node_impl.cpp

示例5: get_data

void session::get_data(const std::error_code& ec,
    const get_data_type& packet, channel_ptr node)
{
    if (ec)
    {
        log_error(LOG_SESSION) << "get_data: " << ec.message();
        return;
    }
    // simple stuff
    node->subscribe_get_data(
        std::bind(&session::get_data, this, _1, _2, node));
}
开发者ID:hellais,项目名称:libbitcoin,代码行数:12,代码来源:session.cpp

示例6: connection_started

void fullnode::connection_started(const std::error_code& ec, channel_ptr node)
{
    if (ec)
    {
        log_warning() << "Couldn't start connection: " << ec.message();
        return;
    }
    // Subscribe to transaction messages from this node.
    node->subscribe_transaction(
        std::bind(&fullnode::recv_tx, this, _1, _2, node));
    // Stay subscribed to new connections.
    protocol_.subscribe_channel(
        std::bind(&fullnode::connection_started, this, _1, _2));
}
开发者ID:lclc,项目名称:libbitcoin,代码行数:14,代码来源:fullnode.cpp

示例7: monitor

void getx_responder::monitor(channel_ptr node)
{
    // Use this wrapper to add shared state to our node for inv
    // requests to trigger getblocks requests so a node can continue
    // downloading blocks.
    channel_with_state special;
    special.node = node;

    // Serve tx and blocks to nodes.
    BITCOIN_ASSERT(node);
    node->subscribe_get_data(
        std::bind(&getx_responder::receive_get_data,
            this, _1, _2, special));
}
开发者ID:libmetrocoin,项目名称:libmetrocoin-node,代码行数:14,代码来源:getx_responder.cpp

示例8: get_blocks

void session::get_blocks(const std::error_code& ec,
    const get_blocks_type& packet, channel_ptr node)
{
    if (ec)
    {
        log_error(LOG_SESSION) << "get_blocks: " << ec.message();
        return;
    }
    // send 500 invs from last fork point
    // have memory of last inv, ready to trigger send next 500 once
    // getdata done for it.
    node->subscribe_get_blocks(
        std::bind(&session::get_blocks, this, _1, _2, node));
}
开发者ID:hellais,项目名称:libbitcoin,代码行数:14,代码来源:session.cpp

示例9: receive_block

void poller::receive_block(const std::error_code& ec,
    const block_type& block, channel_ptr node)
{
    if (!node)
        return;

    if (ec)
    {
        log_warning(LOG_POLLER) << "Received bad block: "
            << ec.message();
        node->stop(/* ec */);
        return;
    }

    blockchain_.store(block,
        strand_.wrap(&poller::handle_store_block,
            this, _1, _2, hash_block_header(block.header), node));

    // Resubscribe.
    node->subscribe_block(
        std::bind(&poller::receive_block,
            this, _1, _2, node));
}
开发者ID:p2plab,项目名称:libbitcoin-node,代码行数:23,代码来源:poller.cpp

示例10: pool_tx

void getx_responder::pool_tx(const std::error_code& code,
    const transaction_type& tx, const hash_digest& tx_hash, channel_ptr node)
{
    if (code)
    {
        chain_.fetch_transaction(tx_hash,
            std::bind(&getx_responder::chain_tx,
                this, _1, _2, node));
    }
    else
    {
        BITCOIN_ASSERT(node);
        node->send(tx, [](const std::error_code&) {});
    }
}
开发者ID:libmetrocoin,项目名称:libmetrocoin-node,代码行数:15,代码来源:getx_responder.cpp

示例11: receive_block

void poller::receive_block(const std::error_code& ec,
                           const block_type& blk, channel_ptr node)
{
    if (ec)
    {
        log_error(LOG_POLLER) << "Received bad block: " << ec.message();
        return;
    }
    chain_.store(blk,
                 std::bind(&poller::handle_store,
                           this, _1, _2, hash_block_header(blk.header), node));
    node->subscribe_block(
        std::bind(&poller::receive_block,
                  this, _1, _2, node));
}
开发者ID:standardcrypto,项目名称:libbitcoin,代码行数:15,代码来源:poller.cpp

示例12: receive_address_message

void protocol::receive_address_message(const std::error_code& ec,
                                       const address_type& packet, channel_ptr node)
{
    if (ec)
    {
        log_error(LOG_PROTOCOL)
                << "Problem receiving addresses: " << ec.message();
        return;
    }
    log_debug(LOG_PROTOCOL) << "Storing addresses.";
    for (const network_address_type& net_address: packet.addresses)
        hosts_.store(net_address, strand_.wrap(
                         &protocol::handle_store_address, this, _1));
    node->subscribe_address(strand_.wrap(
                                &protocol::receive_address_message, this, _1, _2, node));
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:16,代码来源:protocol.cpp

示例13: connection_started

void connection_started(const std::error_code& ec, channel_ptr node,
    protocol& prot, tx_watch& watch)
{
    if (ec)
    {
        log_warning() << "Couldn't start connection: " << ec.message();
        return;
    }
    log_info() << "Connection established.";
    // Subscribe to inventory packets.
    node->subscribe_inventory(
        std::bind(inventory_received, _1, _2, node, std::ref(watch)));
    // Resubscribe to new nodes.
    prot.subscribe_channel(
        std::bind(connection_started, _1, _2, std::ref(prot), std::ref(watch)));
}
开发者ID:RagnarDanneskjold,项目名称:libbitcoin,代码行数:16,代码来源:txrad.cpp

示例14: send_tx

void send_tx(const std::error_code& ec, channel_ptr node, transaction_type& tx)
{
    check_error(ec);
    std::cout << "sendtx: Sending " << hash_transaction(tx) << std::endl;
    auto handle_send =
        [node](const std::error_code& ec)
        {
            if (ec)
                log_warning() << "Send failed: " << ec.message();
            else
                std::cout << "sendtx: Sent "
                    << time(nullptr) << std::endl;
            stopped = true;
        };
    node->send(tx, handle_send);
}
开发者ID:ABISprotocol,项目名称:sx,代码行数:16,代码来源:sendtx-node.cpp

示例15: inventory_received

void inventory_received(const std::error_code& ec, const inventory_type& inv,
    channel_ptr node, tx_watch& watch)
{
    check_error(ec);
    // Loop through inventory hashes.
    for (const inventory_vector_type& ivec: inv.inventories)
    {
        // We're only interested in transactions. Discard everything else.
        if (ivec.type != inventory_type_id::transaction)
            continue;
        watch.push(ivec.hash);
    }
    // Resubscribe to inventory packets.
    node->subscribe_inventory(
        std::bind(inventory_received, _1, _2, node, std::ref(watch)));
}
开发者ID:RagnarDanneskjold,项目名称:libbitcoin,代码行数:16,代码来源:txrad.cpp


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