本文整理汇总了C++中incoming_message类的典型用法代码示例。如果您正苦于以下问题:C++ incoming_message类的具体用法?C++ incoming_message怎么用?C++ incoming_message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了incoming_message类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_renew
void subscribe_manager::do_renew(
const incoming_message& request, queue_send_callback queue_send)
{
payment_address addr_key;
if (!deserialize_address(addr_key, request.data()))
{
log_warning(LOG_SUBSCRIBER) << "Incorrect format for subscribe renew.";
return;
}
const posix_time::ptime now = second_clock::universal_time();
// Find entry and update expiry_time.
auto range = subs_.equal_range(addr_key);
for (auto it = range.first; it != range.second; ++it)
{
subscription& sub = it->second;
// Only update subscriptions which were created by
// the same client as this request originated from.
if (sub.client_origin != request.origin())
continue;
// Future expiry time.
sub.expiry_time = now + sub_expiry;
}
// Send response.
data_chunk result(4);
auto serial = make_serializer(result.begin());
write_error_code(serial, std::error_code());
outgoing_message response(request, result);
queue_send(response);
}
开发者ID:BWallet,项目名称:obelisk,代码行数:29,代码来源:subscribe_manager.cpp
示例2: process_filters
bool backend_cluster::process_filters(const incoming_message& response)
{
auto filter_it = filters_.find(response.command());
if (filter_it == filters_.end())
return false;
filter_it->second(response.data(), response.origin());
return true;
}
开发者ID:Bobalot,项目名称:obelisk,代码行数:8,代码来源:backend.cpp
示例3: process_as_reply
bool backend_cluster::process_as_reply(const incoming_message& response)
{
auto handle_it = handlers_.find(response.id());
// Unknown response. Not in our map.
if (handle_it == handlers_.end())
return false;
handle_it->second(response.data(), response.origin());
handlers_.erase(handle_it);
size_t n_erased = retry_queue_.erase(response.id());
BITCOIN_ASSERT(n_erased == 1);
return true;
}
开发者ID:Bobalot,项目名称:obelisk,代码行数:12,代码来源:backend.cpp
示例4: blockchain_fetch_stealth
void blockchain_fetch_stealth(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& data = request.data();
if (data.empty())
{
log_error(LOG_WORKER)
<< "Incorrect data size (empty) for blockchain.fetch_stealth";
return;
}
auto deserial = make_deserializer(data.begin(), data.end());
// number_bits
uint8_t number_bits = deserial.read_byte();
stealth_prefix prefix(number_bits);
log_info(LOG_WORKER) << data.size() << " " << prefix.num_blocks();
if (data.size() != 1 + prefix.num_blocks() + 4)
{
log_error(LOG_WORKER)
<< "Incorrect data size (" << data.size()
<< ") for blockchain.fetch_stealth";
return;
}
// actual bitfield data
data_chunk bitfield = deserial.read_data(prefix.num_blocks());
boost::from_block_range(bitfield.begin(), bitfield.end(), prefix);
// from_height
size_t from_height = deserial.read_4_bytes();
node.blockchain().fetch_stealth(prefix,
std::bind(stealth_fetched, _1, _2, request, queue_send), from_height);
}
开发者ID:u20024804,项目名称:libbitcoin-server,代码行数:30,代码来源:blockchain.cpp
示例5: protocol_broadcast_transaction
void protocol_broadcast_transaction(server_node& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& raw_tx = request.data();
chain::transaction tx;
data_chunk result(4);
auto serial = make_serializer(result.begin());
if (!tx.from_data(raw_tx))
{
// error
write_error_code(serial, error::bad_stream);
outgoing_message response(request, result);
queue_send(response);
return;
}
auto ignore_send = [](const std::error_code&, size_t) {};
// Send and hope for the best!
node.protocol().broadcast(tx, ignore_send);
// Response back to user saying everything is fine.
write_error_code(serial, std::error_code());
log_debug(LOG_SERVICE)
<< "protocol.broadcast_transaction() finished. Sending response.";
outgoing_message response(request, result);
queue_send(response);
}
开发者ID:tuomassiren,项目名称:libbitcoin-server,代码行数:31,代码来源:protocol.cpp
示例6: add_subscription
std::error_code subscribe_manager::add_subscription(
const incoming_message& request, queue_send_callback queue_send)
{
payment_address addr_key;
if (!deserialize_address(addr_key, request.data()))
{
log_warning(LOG_SUBSCRIBER) << "Incorrect format for subscribe data.";
return error::bad_stream;
}
// Now create subscription.
const posix_time::ptime now = second_clock::universal_time();
// Limit absolute number of subscriptions to prevent exhaustion attacks.
if (subs_.size() >= subscribe_limit_)
return error::pool_filled;
subs_.emplace(addr_key, subscription{
now + sub_expiry, request.origin(), queue_send});
return std::error_code();
}
开发者ID:BWallet,项目名称:obelisk,代码行数:18,代码来源:subscribe_manager.cpp
示例7: fetch_block_header_by_height
void fetch_block_header_by_height(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& data = request.data();
BITCOIN_ASSERT(data.size() == 4);
auto deserial = make_deserializer(data.begin(), data.end());
size_t height = deserial.read_4_bytes();
node.blockchain().fetch_block_header(height,
std::bind(block_header_fetched, _1, _2, request, queue_send));
}
开发者ID:u20024804,项目名称:libbitcoin-server,代码行数:10,代码来源:blockchain.cpp
示例8: fetch_block_header_by_hash
void fetch_block_header_by_hash(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& data = request.data();
BITCOIN_ASSERT(data.size() == 32);
auto deserial = make_deserializer(data.begin(), data.end());
const hash_digest blk_hash = deserial.read_hash();
node.blockchain().fetch_block_header(blk_hash,
std::bind(block_header_fetched, _1, _2, request, queue_send));
}
开发者ID:u20024804,项目名称:libbitcoin-server,代码行数:10,代码来源:blockchain.cpp
示例9: do_subscribe
void subscribe_manager::do_subscribe(
const incoming_message& request, zmq_socket_ptr socket)
{
payment_address addr_key;
if (!deserialize_address(addr_key, request.data()))
{
log_warning(LOG_SUBSCRIBER) << "Incorrect format for subscribe data.";
return;
}
// Now create subscription.
const posix_time::ptime now = second_clock::universal_time();
subs_.emplace(addr_key, subscription{
now + sub_expiry, request.origin(), socket});
// Send response.
data_chunk result(4);
auto serial = make_serializer(result.begin());
write_error_code(serial, std::error_code());
outgoing_message response(request, result);
response.send(*socket);
}
开发者ID:Bobalot,项目名称:obelisk,代码行数:20,代码来源:subscribe_manager.cpp
示例10: blockchain_fetch_last_height
void blockchain_fetch_last_height(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& data = request.data();
if (!data.empty())
{
log_error(LOG_WORKER)
<< "Incorrect data size for blockchain.fetch_last_height";
return;
}
node.blockchain().fetch_last_height(
std::bind(last_height_fetched, _1, _2, request, queue_send));
}
开发者ID:u20024804,项目名称:libbitcoin-server,代码行数:13,代码来源:blockchain.cpp
示例11: unwrap_fetch_transaction_args
bool unwrap_fetch_transaction_args(
hash_digest& tx_hash, const incoming_message& request)
{
const data_chunk& data = request.data();
if (data.size() != 32)
{
log_error(LOG_WORKER)
<< "Incorrect data size for *.fetch_transaction";
return false;
}
auto deserial = make_deserializer(data.begin(), data.end());
tx_hash = deserial.read_hash();
return true;
}
开发者ID:BitcoinKinetics,项目名称:obelisk,代码行数:14,代码来源:fetch_x.cpp
示例12: blockchain_fetch_block_header
void blockchain_fetch_block_header(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& data = request.data();
if (data.size() == 32)
fetch_block_header_by_hash(node, request, queue_send);
else if (data.size() == 4)
fetch_block_header_by_height(node, request, queue_send);
else
{
log_error(LOG_WORKER)
<< "Incorrect data size for blockchain.fetch_block_header";
return;
}
}
开发者ID:u20024804,项目名称:libbitcoin-server,代码行数:15,代码来源:blockchain.cpp
示例13: blockchain_fetch_block_height
void blockchain_fetch_block_height(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& data = request.data();
if (data.size() != 32)
{
log_error(LOG_WORKER)
<< "Incorrect data size for blockchain.fetch_block_height";
return;
}
auto deserial = make_deserializer(data.begin(), data.end());
const hash_digest blk_hash = deserial.read_hash();
node.blockchain().fetch_block_height(blk_hash,
std::bind(block_height_fetched, _1, _2, request, queue_send));
}
开发者ID:u20024804,项目名称:libbitcoin-server,代码行数:15,代码来源:blockchain.cpp
示例14: blockchain_fetch_spend
void blockchain_fetch_spend(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& data = request.data();
if (data.size() != 36)
{
log_error(LOG_WORKER)
<< "Incorrect data size for blockchain.fetch_spend";
return;
}
auto deserial = make_deserializer(data.begin(), data.end());
output_point outpoint;
outpoint.hash = deserial.read_hash();
outpoint.index = deserial.read_4_bytes();
node.blockchain().fetch_spend(outpoint,
std::bind(spend_fetched, _1, _2, request, queue_send));
}
开发者ID:u20024804,项目名称:libbitcoin-server,代码行数:17,代码来源:blockchain.cpp
示例15: unwrap_fetch_history_args
bool unwrap_fetch_history_args(
payment_address& payaddr, uint32_t& from_height,
const incoming_message& request)
{
const data_chunk& data = request.data();
if (data.size() != 1 + short_hash_size + 4)
{
log_error(LOG_WORKER)
<< "Incorrect data size for .fetch_history";
return false;
}
auto deserial = make_deserializer(data.begin(), data.end());
uint8_t version_byte = deserial.read_byte();
short_hash hash = deserial.read_short_hash();
from_height = deserial.read_4_bytes();
BITCOIN_ASSERT(deserial.iterator() == data.end());
payaddr.set(version_byte, hash);
return true;
}
开发者ID:BitcoinKinetics,项目名称:obelisk,代码行数:19,代码来源:fetch_x.cpp
示例16: transaction_pool_validate
void transaction_pool_validate(node_impl& node,
const incoming_message& request, queue_send_callback queue_send)
{
const data_chunk& raw_tx = request.data();
transaction_type tx;
try
{
satoshi_load(raw_tx.begin(), raw_tx.end(), tx);
}
catch (end_of_stream)
{
// error
transaction_validated(error::bad_stream, index_list(),
request, queue_send);
return;
}
node.transaction_pool().validate(tx,
std::bind(transaction_validated, _1, _2, request, queue_send));
}
开发者ID:prodigeni,项目名称:obelisk,代码行数:19,代码来源:transaction_pool.cpp
示例17:
outgoing_message::outgoing_message(
const incoming_message& request, const data_chunk& data)
: dest_(request.origin()), command_(request.command()),
id_(request.id()), data_(data)
{
}
开发者ID:Belxjander,项目名称:Kirito,代码行数:6,代码来源:message.cpp
注:本文中的incoming_message类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论