mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
* Addressbook : move storage init code from constructor to Init() : was too early
This commit is contained in:
parent
85bd7a63c6
commit
2a4ba8d349
|
@ -27,21 +27,21 @@ namespace client
|
||||||
std::string indexPath;
|
std::string indexPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AddressBookFilesystemStorage ();
|
AddressBookFilesystemStorage (): storage("addressbook", "b", "", "b32") {};
|
||||||
std::shared_ptr<const i2p::data::IdentityEx> GetAddress (const i2p::data::IdentHash& ident) const;
|
std::shared_ptr<const i2p::data::IdentityEx> GetAddress (const i2p::data::IdentHash& ident) const;
|
||||||
void AddAddress (std::shared_ptr<const i2p::data::IdentityEx> address);
|
void AddAddress (std::shared_ptr<const i2p::data::IdentityEx> address);
|
||||||
void RemoveAddress (const i2p::data::IdentHash& ident);
|
void RemoveAddress (const i2p::data::IdentHash& ident);
|
||||||
|
|
||||||
|
bool Init ();
|
||||||
int Load (std::map<std::string, i2p::data::IdentHash>& addresses);
|
int Load (std::map<std::string, i2p::data::IdentHash>& addresses);
|
||||||
int Save (const std::map<std::string, i2p::data::IdentHash>& addresses);
|
int Save (const std::map<std::string, i2p::data::IdentHash>& addresses);
|
||||||
};
|
};
|
||||||
|
|
||||||
AddressBookFilesystemStorage::AddressBookFilesystemStorage():
|
bool AddressBookFilesystemStorage::Init()
|
||||||
storage("addressbook", "b", "", "b32")
|
|
||||||
{
|
{
|
||||||
storage.SetPlace(i2p::fs::GetDataDir());
|
storage.SetPlace(i2p::fs::GetDataDir());
|
||||||
storage.Init(i2p::data::GetBase32SubstitutionTable(), 32);
|
|
||||||
indexPath = storage.GetRoot() + i2p::fs::dirSep + "addresses.csv";
|
indexPath = storage.GetRoot() + i2p::fs::dirSep + "addresses.csv";
|
||||||
|
return storage.Init(i2p::data::GetBase32SubstitutionTable(), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const i2p::data::IdentityEx> AddressBookFilesystemStorage::GetAddress (const i2p::data::IdentHash& ident) const
|
std::shared_ptr<const i2p::data::IdentityEx> AddressBookFilesystemStorage::GetAddress (const i2p::data::IdentHash& ident) const
|
||||||
|
@ -159,6 +159,7 @@ namespace client
|
||||||
|
|
||||||
void AddressBook::Start ()
|
void AddressBook::Start ()
|
||||||
{
|
{
|
||||||
|
m_Storage->Init();
|
||||||
LoadHosts (); /* try storage, then hosts.txt, then download */
|
LoadHosts (); /* try storage, then hosts.txt, then download */
|
||||||
StartSubscriptions ();
|
StartSubscriptions ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace client
|
||||||
virtual void AddAddress (std::shared_ptr<const i2p::data::IdentityEx> address) = 0;
|
virtual void AddAddress (std::shared_ptr<const i2p::data::IdentityEx> address) = 0;
|
||||||
virtual void RemoveAddress (const i2p::data::IdentHash& ident) = 0;
|
virtual void RemoveAddress (const i2p::data::IdentHash& ident) = 0;
|
||||||
|
|
||||||
|
virtual bool Init () = 0;
|
||||||
virtual int Load (std::map<std::string, i2p::data::IdentHash>& addresses) = 0;
|
virtual int Load (std::map<std::string, i2p::data::IdentHash>& addresses) = 0;
|
||||||
virtual int Save (const std::map<std::string, i2p::data::IdentHash>& addresses) = 0;
|
virtual int Save (const std::map<std::string, i2p::data::IdentHash>& addresses) = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue