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); }
void protocol_total_connections(server_node& node, const incoming_message& request, queue_send_callback queue_send) { BITCOIN_ASSERT(node.protocol().total_connections() <= max_uint32); const auto total_connections32 = static_cast<uint32_t>( node.protocol().total_connections()); data_chunk result(8); auto serial = make_serializer(result.begin()); write_error_code(serial, std::error_code()); serial.write_4_bytes_little_endian(total_connections32); BITCOIN_ASSERT(serial.iterator() == result.end()); log_debug(LOG_REQUEST) << "protocol.total_connections() finished. Sending response."; outgoing_message response(request, result); queue_send(response); }