MCPcopy Create free account
hub / github.com/bcndev/bytecoin / P2P

Method P2P

src/p2p/P2P.cpp:263–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263P2P::P2P(logging::ILogger &log, const Config &config, PeerDB &peers, client_factory &&c_factory)
264 : m_config(config)
265 , m_log(log, "P2P")
266 , peers(peers)
267 , m_log_banned_timestamp(std::chrono::steady_clock::now())
268 , reconnect_timer(std::bind(&P2P::connect_all_nodelay, this))
269 , free_disconnected_timer([&]() { disconnected_clients.clear(); })
270 , c_factory(std::move(c_factory))
271 , unique_number(crypto::rand<uint64_t>()) {
272 try {
273 la_socket = std::make_unique<platform::TCPAcceptor>(
274 config.p2p_bind_ip, config.p2p_bind_port, std::bind(&P2P::accept_all, this));
275 common::console::set_text_color(common::console::BrightGreen);
276 m_log(logging::INFO) << "P2P listening on " << config.p2p_bind_ip << ":" << config.p2p_bind_port;
277 common::console::set_text_color(common::console::Default);
278 } catch (const std::runtime_error &ex) {
279 m_log(logging::WARNING) << " failed to create listening socket, what=" << common::what(ex)
280 << ", working with outbound connections only";
281 }
282 connect_all();
283 accept_all();
284}
285
286Timestamp P2P::get_local_time() const { return platform::now_unix_timestamp(); }

Callers

nothing calls this directly

Calls 2

set_text_colorFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected