本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}