MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / RouterContext

Method RouterContext

libi2pd/RouterContext.cpp:32–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 RouterContext context;
31
32 RouterContext::RouterContext ():
33 m_LastUpdateTime (0), m_AcceptsTunnels (true), m_IsFloodfill (false),
34 m_ShareRatio (100), m_Status (eRouterStatusUnknown), m_StatusV6 (eRouterStatusUnknown),
35 m_Error (eRouterErrorNone), m_ErrorV6 (eRouterErrorNone),
36 m_Testing (false), m_TestingV6 (false), m_NetID (I2PD_NET_ID),
37 m_PublishReplyToken (0), m_IsHiddenMode (false)
38#if __cplusplus < 202002L // C++20
39 , m_IsSaving ATOMIC_FLAG_INIT // {0}
40#endif
41 {
42 }
43
44 void RouterContext::Init ()
45 {
46 srand (GetRng ()() % 1000);
47 m_StartupTime = i2p::util::GetMonotonicSeconds ();
48
49 if (!Load ())
50 CreateNewRouter ();
51 m_Decryptor = m_Keys.CreateDecryptor (nullptr);
52 m_TunnelDecryptor = m_Keys.CreateDecryptor (nullptr);
53 UpdateRouterInfo ();
54 i2p::crypto::InitNoiseNState (m_InitialNoiseState, GetIdentity ()->GetEncryptionPublicKey ());
55 m_ECIESSession = std::make_shared<i2p::garlic::RouterIncomingRatchetSession>(m_InitialNoiseState);
56 }
57
58 void RouterContext::Start ()
59 {
60 if (!m_Service)
61 {
62 m_Service.reset (new RouterService);
63 m_Service->Start ();
64 m_PublishTimer.reset (new boost::asio::steady_timer (m_Service->GetService ()));
65 ScheduleInitialPublish ();
66 m_CongestionUpdateTimer.reset (new boost::asio::steady_timer (m_Service->GetService ()));
67 ScheduleCongestionUpdate ();
68 m_CleanupTimer.reset (new boost::asio::steady_timer (m_Service->GetService ()));
69 ScheduleCleanupTimer ();
70 }
71 }
72
73 void RouterContext::Stop ()
74 {

Callers

nothing calls this directly

Calls 5

GetMonotonicSecondsFunction · 0.85
InitNoiseNStateFunction · 0.85
CreateDecryptorMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected