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


C++ channel_ptr::subscribe_block方法代码示例

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


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

示例1: monitor

void poller::monitor(channel_ptr node)
{
    node->subscribe_inventory(
        strand_.wrap(std::bind(&poller::receive_inv,
                               this, _1, _2, node)));
    node->subscribe_block(
        std::bind(&poller::receive_block,
                  this, _1, _2, node));
}
开发者ID:standardcrypto,项目名称:libbitcoin,代码行数:9,代码来源:poller.cpp

示例2: ask_blocks

void ask_blocks(const std::error_code& ec, channel_ptr node,
    const message::block_locator& loc, blockchain_ptr chain,
    const hash_digest& hash_stop)
{
    if (ec)
        log_error() << ec.message();
    node->subscribe_inventory(std::bind(recv_inv, _1, _2, node));
    node->subscribe_block(std::bind(recv_blk, _1, _2, node, chain));

    message::get_blocks packet;
    packet.start_hashes = loc;
    packet.hash_stop = hash_stop;
    node->send(packet, std::bind(&handle_send_packet, _1));
}
开发者ID:Phallanx,项目名称:libbitcoin,代码行数:14,代码来源:bdb-test.cpp

示例3: handle_connect

void handle_connect(const std::error_code& ec, channel_ptr node)
{
    recv_node = node;
    message::get_data getdat;
    getdat.inventories.push_back(
        {message::inventory_type::transaction,
            hash_from_pretty<hash_digest>("e72e4f025695446cfd5c5349d1720beb38801f329a00281f350cb7e847153397")});
    getdat.inventories.push_back(
        {message::inventory_type::block,
            hash_from_pretty<hash_digest>("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")});
    node->subscribe_block(handle_blk);
    sleep(1);
    node->send(getdat, handle_send);
}
开发者ID:Phallanx,项目名称:libbitcoin,代码行数:14,代码来源:getx.cpp

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

示例5: monitor

// Start monitoring this channel.
void poller::monitor(channel_ptr node)
{
    if (!node)
    {
        log_error(LOG_POLLER)
            << "The node is not initialized and cannot be monitored.";
        return;
    }

    //////node->subscribe_inventory(
    //////    std::bind(&poller::receive_inv,
    //////        this, _1, _2, node));

    node->subscribe_block(
        std::bind(&poller::receive_block,
            this, _1, _2, node));

    // Issue the initial ask for blocks.
    request_blocks(null_hash, node);
}
开发者ID:p2plab,项目名称:libbitcoin-node,代码行数:21,代码来源:poller.cpp

示例6: recv_blk

void recv_blk(const std::error_code& ec, const message::block& packet,
    channel_ptr node, blockchain_ptr chain)
{
    static bool stop_inserts = false;
    if (ec)
        log_error() << ec.message();
    node->subscribe_block(std::bind(recv_blk, _1, _2, node, chain));
    // store block in bdb
    //if (hash_block_header(packet) ==
    //    hash_digest{0x00, 0x00, 0x00, 0x00, 0xd1, 0x14, 0x57, 0x90,
    //                0xa8, 0x69, 0x44, 0x03, 0xd4, 0x06, 0x3f, 0x32,
    //                0x3d, 0x49, 0x9e, 0x65, 0x5c, 0x83, 0x42, 0x68,
    //                0x34, 0xd4, 0xce, 0x2f, 0x8d, 0xd4, 0xa2, 0xee})
    //{
    //    test_mem_pool(packet);
    //    stop_inserts = true;
    //}
    //else if (!stop_inserts)
        chain->store(packet, std::bind(handle_store, _1, _2, node, chain, hash_block_header(packet)));
}
开发者ID:Phallanx,项目名称:libbitcoin,代码行数:20,代码来源:bdb-test.cpp

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


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