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


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

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


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

示例1: recv_tx

void fullnode::recv_tx(const std::error_code& ec,
    const transaction_type& tx, channel_ptr node)
{
    if (ec)
    {
        log_error() << "Receive transaction: " << ec.message();
        return;
    }
    auto handle_deindex = [](const std::error_code& ec)
        {
            if (ec)
                log_error() << "Deindex error: " << ec.message();
        };
    // Called when the transaction becomes confirmed in a block.
    auto handle_confirm = [this, tx, handle_deindex](
        const std::error_code& ec)
        {
            log_debug() << "handle_confirm ec = " << ec.message()
                << " " << hash_transaction(tx);
            if (ec)
                log_error() << "Confirm error ("
                    << hash_transaction(tx) << "): " << ec.message();
            txidx_.deindex(tx, handle_deindex);
        };
    // Validate the transaction from the network.
    // Attempt to store in the transaction pool and check the result.
    txpool_.store(tx, handle_confirm,
        std::bind(&fullnode::new_unconfirm_valid_tx, this, _1, _2, tx));
    // Resubscribe to transaction messages from this node.
    node->subscribe_transaction(
        std::bind(&fullnode::recv_tx, this, _1, _2, node));
}
开发者ID:lclc,项目名称:libbitcoin,代码行数:32,代码来源:fullnode.cpp

示例2: recv_transaction

void node_impl::recv_transaction(const std::error_code& ec,
    const transaction_type& tx, channel_ptr node)
{
    if (ec)
    {
        log_error() << "recv_transaction: " << ec.message();
        return;
    }
    auto handle_deindex = [](const std::error_code& ec)
    {
        if (ec)
            log_error() << "Deindex error: " << ec.message();
    };
    // Called when the transaction becomes confirmed in a block.
    auto handle_confirm = [this, tx, handle_deindex](
        const std::error_code& ec)
    {
        log_debug() << "Confirm transaction: " << ec.message()
            << " " << hash_transaction(tx);
        // Always try to deindex tx.
        // The error could be error::forced_removal from txpool.
        indexer_.deindex(tx, handle_deindex);
    };
    txpool_.store(tx, handle_confirm,
        std::bind(&node_impl::handle_mempool_store, this, _1, _2, tx, node));
    node->subscribe_transaction(
        std::bind(&node_impl::recv_transaction, this, _1, _2, node));
}
开发者ID:litecoin-extras,项目名称:obelisk,代码行数:28,代码来源:node_impl.cpp

示例3: handle_accept

 void handle_accept(const std::error_code& ec, channel_ptr node)
 {
     if (ec)
         error_exit(ec);
     log_info() << "Connected";
     node->subscribe_transaction(
         std::bind(&echo_app::handle_receive_tx, this, _1, _2, node));
 }
开发者ID:Phallanx,项目名称:libbitcoin,代码行数:8,代码来源:echo.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: 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

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

void monitor_tx(channel_ptr node)
{
    node->subscribe_transaction(std::bind(&recv_transaction, _1, _2, node));
    p->protocol_.subscribe_channel(monitor_tx);
}
开发者ID:bitkevin,项目名称:libbitcoin,代码行数:5,代码来源:sesh.cpp


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