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