diff --git a/libi2pd/Config.cpp b/libi2pd/Config.cpp index d9cc6dec..11e0966b 100644 --- a/libi2pd/Config.cpp +++ b/libi2pd/Config.cpp @@ -231,6 +231,11 @@ namespace config { ("exploratory.outbound.quantity", value()->default_value(3), "Exploratory outbound tunnels quantity") ; + options_description storage("Persistent storage options for NetDb, profiles, etc."); + storage.add_options() + ("storage.engine", value()->default_value("fs"), "Storage engine") + ; + m_OptionsDesc .add(general) .add(limits) @@ -248,6 +253,7 @@ namespace config { .add(trust) .add(websocket) .add(exploratory) + .add(storage) ; } diff --git a/libi2pd/NetDb.cpp b/libi2pd/NetDb.cpp index 0cd74bd4..b966ebcf 100644 --- a/libi2pd/NetDb.cpp +++ b/libi2pd/NetDb.cpp @@ -37,7 +37,13 @@ namespace data void NetDb::Start () { - m_Storage.reset(new FsIdentStorage("netDb", "r", "routerInfo-", "dat")); + std::string engine; + i2p::config::GetOption("storage.engine", engine); + if (engine == "lmdb") + m_Storage.reset(new MdbIdentStorage("netDb.lmdb")); + else + m_Storage.reset(new FsIdentStorage("netDb", "r", "routerInfo-", "dat")); + m_Storage->Init(); InitProfilesStorage (); m_Families.LoadCertificates (); diff --git a/libi2pd/Profiling.cpp b/libi2pd/Profiling.cpp index aab3a6c6..2f7cb546 100644 --- a/libi2pd/Profiling.cpp +++ b/libi2pd/Profiling.cpp @@ -2,6 +2,7 @@ #include #include #include "Base.h" +#include "Config.h" #include "FS.h" #include "Log.h" #include "Profiling.h" @@ -173,7 +174,12 @@ namespace data void InitProfilesStorage () { - m_ProfilesStorage.reset(new FsIdentStorage("peerProfiles", "p", "profile-", "txt")); + std::string engine; + i2p::config::GetOption("storage.engine", engine); + if (engine == "lmdb") + m_ProfilesStorage.reset(new MdbIdentStorage("peerProfiles.lmdb")); + else + m_ProfilesStorage.reset(new FsIdentStorage("peerProfiles", "p", "profile-", "txt")); m_ProfilesStorage->Init(); }