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

Method Save

libi2pd/Profiling.cpp:51–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 }
50
51 void RouterProfile::Save (const IdentHash& identHash)
52 {
53 // fill sections
54 boost::property_tree::ptree participation;
55 participation.put (PEER_PROFILE_PARTICIPATION_AGREED, m_NumTunnelsAgreed);
56 participation.put (PEER_PROFILE_PARTICIPATION_DECLINED, m_NumTunnelsDeclined);
57 participation.put (PEER_PROFILE_PARTICIPATION_NON_REPLIED, m_NumTunnelsNonReplied);
58 boost::property_tree::ptree usage;
59 usage.put (PEER_PROFILE_USAGE_TAKEN, m_NumTimesTaken);
60 usage.put (PEER_PROFILE_USAGE_REJECTED, m_NumTimesRejected);
61 usage.put (PEER_PROFILE_USAGE_CONNECTED, m_HasConnected);
62 if (m_IsDuplicated)
63 usage.put (PEER_PROFILE_USAGE_DUPLICATED, true);
64 // fill property tree
65 boost::property_tree::ptree pt;
66 pt.put (PEER_PROFILE_LAST_UPDATE_TIMESTAMP, m_LastUpdateTime);
67 if (m_LastUnreachableTime)
68 pt.put (PEER_PROFILE_LAST_UNREACHABLE_TIME, m_LastUnreachableTime);
69 pt.put_child (PEER_PROFILE_SECTION_PARTICIPATION, participation);
70 pt.put_child (PEER_PROFILE_SECTION_USAGE, usage);
71
72 // save to file
73 std::string ident = identHash.ToBase64 ();
74 std::string path = g_ProfilesStorage.Path(ident);
75
76 try {
77 boost::property_tree::write_ini (path, pt);
78 } catch (std::exception& ex) {
79 /* boost exception verbose enough */
80 LogPrint (eLogError, "Profiling: ", ex.what ());
81 }
82 }
83
84 void RouterProfile::Load (const IdentHash& identHash)
85 {

Callers 2

Profiling.cppFile · 0.45
SaveProfilesFunction · 0.45

Calls 3

LogPrintFunction · 0.85
ToBase64Method · 0.80
PathMethod · 0.80

Tested by

no test coverage detected