// Require the configured minimum and services by default. // Configured min version is our own but we may require higer for some stuff. // Configured services are our own and may not always make sense to require. protocol_version_31402::protocol_version_31402(p2p& network, channel::ptr channel) : protocol_version_31402(network, channel, network.network_settings().protocol_maximum, network.network_settings().services, network.network_settings().protocol_minimum, network.network_settings().services) { }
session::session(p2p& network, bool notify_on_connect) : stopped_(true), notify_on_connect_(notify_on_connect), network_(network), settings_(network.network_settings()), pool_(network.thread_pool()), dispatch_(pool_, NAME) { }
session::session(p2p& network, bool outgoing, bool persistent) : stopped_(true), incoming_(!outgoing), notify_(persistent), network_(network), settings_(network.network_settings()), pool_(network.thread_pool()), dispatch_(pool_, NAME) { }
static int subscribe_result(p2p& network, const config::endpoint& host) { std::promise<code> promise; const auto handler = [&promise](const code& ec, channel::ptr) { promise.set_value(ec); }; network.subscribe(handler); network.connect(host.host(), host.port()); return promise.get_future().get().value(); }
static int subscribe_result(p2p& network) { std::promise<code> promise; const auto handler = [&promise](const code& ec, channel::ptr) { promise.set_value(ec); }; network.subscribe(handler); return promise.get_future().get().value(); }
static int stop_result(p2p& network) { std::promise<code> promise; const auto handler = [&promise](const code& ec) { promise.set_value(ec); }; network.stop(handler); return promise.get_future().get().value(); }
static int send_result(const Message& message, p2p& network, int channels) { const auto channel_counter = [&channels](const code& ec, channel::ptr channel) { BOOST_REQUIRE_EQUAL(ec, error::success); --channels; }; std::promise<code> promise; const auto completion_counter = [&promise](const code& ec) { promise.set_value(ec); }; network.broadcast(message, channel_counter, completion_counter); const auto result = promise.get_future().get().value(); BOOST_REQUIRE_EQUAL(channels, 0); return result; }
protocol_ping::protocol_ping(p2p& network, channel::ptr channel) : protocol_timer(network, channel, true, NAME), settings_(network.network_settings()), CONSTRUCT_TRACK(protocol_ping) { }