mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Set max number of connections for peer db (#2506)
Use max_peers value for that if set. By default LMDB limit is 126, which is not enough for less than 200 peers on my node.
This commit is contained in:
parent
987fa033ed
commit
267c706e2b
2 changed files with 12 additions and 3 deletions
|
@ -161,7 +161,11 @@ impl Server {
|
||||||
config.clone(),
|
config.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let peer_db_env = Arc::new(store::new_named_env(config.db_root.clone(), "peer".into()));
|
let peer_db_env = Arc::new(store::new_named_env(
|
||||||
|
config.db_root.clone(),
|
||||||
|
"peer".into(),
|
||||||
|
config.p2p_config.peer_max_count,
|
||||||
|
));
|
||||||
let p2p_server = Arc::new(p2p::Server::new(
|
let p2p_server = Arc::new(p2p::Server::new(
|
||||||
peer_db_env,
|
peer_db_env,
|
||||||
config.p2p_config.capabilities,
|
config.p2p_config.capabilities,
|
||||||
|
|
|
@ -59,12 +59,12 @@ pub fn option_to_not_found<T>(res: Result<Option<T>, Error>, field_name: &str) -
|
||||||
/// Be aware of transactional semantics in lmdb
|
/// Be aware of transactional semantics in lmdb
|
||||||
/// (transactions are per environment, not per database).
|
/// (transactions are per environment, not per database).
|
||||||
pub fn new_env(path: String) -> lmdb::Environment {
|
pub fn new_env(path: String) -> lmdb::Environment {
|
||||||
new_named_env(path, "lmdb".into())
|
new_named_env(path, "lmdb".into(), None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO - We probably need more flexibility here, 500GB probably too big for peers...
|
/// TODO - We probably need more flexibility here, 500GB probably too big for peers...
|
||||||
/// Create a new LMDB env under the provided directory with the provided name.
|
/// Create a new LMDB env under the provided directory with the provided name.
|
||||||
pub fn new_named_env(path: String, name: String) -> lmdb::Environment {
|
pub fn new_named_env(path: String, name: String, max_readers: Option<u32>) -> lmdb::Environment {
|
||||||
let full_path = [path, name].join("/");
|
let full_path = [path, name].join("/");
|
||||||
fs::create_dir_all(&full_path)
|
fs::create_dir_all(&full_path)
|
||||||
.expect("Unable to create directory 'db_root' to store chain_data");
|
.expect("Unable to create directory 'db_root' to store chain_data");
|
||||||
|
@ -78,6 +78,11 @@ pub fn new_named_env(path: String, name: String) -> lmdb::Environment {
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
panic!("Unable to allocate LMDB space: {:?}", e);
|
panic!("Unable to allocate LMDB space: {:?}", e);
|
||||||
});
|
});
|
||||||
|
if let Some(max_readers) = max_readers {
|
||||||
|
env_builder
|
||||||
|
.set_maxreaders(max_readers)
|
||||||
|
.expect("Unable set max_readers");
|
||||||
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
env_builder
|
env_builder
|
||||||
.open(&full_path, lmdb::open::NOTLS, 0o600)
|
.open(&full_path, lmdb::open::NOTLS, 0o600)
|
||||||
|
|
Loading…
Reference in a new issue