mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Persist discovered peers to config. (#246)
This commit is contained in:
15
src/conf.cpp
15
src/conf.cpp
@@ -789,6 +789,21 @@ namespace conf
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists the specified known peers to the config file.
|
||||
*/
|
||||
int persist_known_peers_config(const std::vector<peer_properties> &peers)
|
||||
{
|
||||
if (peers.empty())
|
||||
return 0;
|
||||
|
||||
const size_t max_count = conf::cfg.mesh.max_known_connections == 0
|
||||
? peers.size()
|
||||
: MIN(peers.size(), conf::cfg.mesh.max_known_connections);
|
||||
cfg.mesh.known_peers = std::vector<peer_properties>(peers.begin(), peers.begin() + max_count);
|
||||
return write_config(cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks the config file. If already locked means there's another hpcore instance running in the same directory.
|
||||
* If so, log error and return, Otherwise lock the config.
|
||||
|
||||
Reference in New Issue
Block a user