MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ThreadI2PAcceptIncoming

Method ThreadI2PAcceptIncoming

src/net.cpp:3234–3277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3232}
3233
3234void CConnman::ThreadI2PAcceptIncoming()
3235{
3236 AssertLockNotHeld(m_nodes_mutex);
3237
3238 static constexpr auto err_wait_begin = 1s;
3239 static constexpr auto err_wait_cap = 5min;
3240 auto err_wait = err_wait_begin;
3241
3242 bool advertising_listen_addr = false;
3243 i2p::Connection conn;
3244
3245 auto SleepOnFailure = [&]() {
3246 m_interrupt_net->sleep_for(err_wait);
3247 if (err_wait < err_wait_cap) {
3248 err_wait += 1s;
3249 }
3250 };
3251
3252 while (!m_interrupt_net->interrupted()) {
3253
3254 if (!m_i2p_sam_session->Listen(conn)) {
3255 if (advertising_listen_addr && conn.me.IsValid()) {
3256 RemoveLocal(conn.me);
3257 advertising_listen_addr = false;
3258 }
3259 SleepOnFailure();
3260 continue;
3261 }
3262
3263 if (!advertising_listen_addr) {
3264 AddLocal(conn.me, LOCAL_MANUAL);
3265 advertising_listen_addr = true;
3266 }
3267
3268 if (!m_i2p_sam_session->Accept(conn)) {
3269 SleepOnFailure();
3270 continue;
3271 }
3272
3273 CreateNodeFromAcceptedSocket(std::move(conn.sock), NetPermissionFlags::None, conn.me, conn.peer);
3274
3275 err_wait = err_wait_begin;
3276 }
3277}
3278
3279void CConnman::ThreadPrivateBroadcast()
3280{

Callers

nothing calls this directly

Calls 7

RemoveLocalFunction · 0.85
AddLocalFunction · 0.85
sleep_forMethod · 0.45
interruptedMethod · 0.45
ListenMethod · 0.45
IsValidMethod · 0.45
AcceptMethod · 0.45

Tested by

no test coverage detected