Increase size of in-memory db

This commit is contained in:
Artem Vorotnikov
2021-05-05 11:02:31 +03:00
parent 419b6374e0
commit c0aeba3467
2 changed files with 9 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ anyhow = "1"
arrayref = "0.3"
async-stream = "0.3"
async-trait = "0.1"
byte-unit = "4"
bytes = { package = "lifetimed-bytes", git = "https://github.com/vorot93/lifetimed-bytes" }
const_format = "0.2"
ethereum = "0.7"

View File

@@ -2,8 +2,9 @@ pub mod mdbx;
pub mod remote;
pub mod traits;
use ::mdbx::WriteMap;
use ::mdbx::{Geometry, WriteMap};
use async_trait::async_trait;
use byte_unit::n_mb_bytes;
pub struct MemoryKv {
inner: mdbx::Environment<WriteMap>,
@@ -32,6 +33,12 @@ pub fn new_mem_database() -> anyhow::Result<impl traits::MutableKV> {
let tmpdir = tempfile::tempdir()?;
let mut builder = ::mdbx::GenericEnvironment::<WriteMap>::new();
builder.set_max_dbs(crate::tables::TABLE_MAP.len());
builder.set_geometry(Geometry {
size: Some(0..n_mb_bytes!(64) as usize),
growth_step: None,
shrink_threshold: None,
page_size: None,
});
let inner = mdbx::Environment::open(builder, tmpdir.path(), &crate::tables::TABLE_MAP)?;
Ok(MemoryKv {