diff --git a/src/keri/db/dbing.py b/src/keri/db/dbing.py index bd2db031..62a2b40f 100644 --- a/src/keri/db/dbing.py +++ b/src/keri/db/dbing.py @@ -59,8 +59,11 @@ from hio.base import filing +from .. import help from ..help import helping +logger = help.ogler.getLogger() + ProemSize = 32 # does not include trailing separator MaxProem = int("f"*(ProemSize), 16) MaxON = int("f"*32, 16) # largest possible ordinal number, sequence or first seen @@ -68,6 +71,8 @@ SuffixSize = 32 # does not include trailing separator MaxSuffix = int("f"*(SuffixSize), 16) +KERIDBMapSizeKey = "KERI_DB_MAP_SIZE" + def dgKey(pre, dig): """ Returns bytes DB key from concatenation of '.' with qualified Base64 prefix @@ -381,6 +386,13 @@ def reopen(self, readonly=False, **kwa): # open lmdb major database instance # creates files data.mdb and lock.mdb in .dbDirPath + if (mapSize := os.getenv(KERIDBMapSizeKey)) is not None: + try: + self.MapSize = int(mapSize) + except ValueError: + logger.error("KERI_DB_MAP_SIZE must be an integer value >1!") + raise + self.env = lmdb.open(self.path, max_dbs=self.MaxNamedDBs, map_size=self.MapSize, mode=self.perm, readonly=self.readonly) self.opened = True if opened and self.env else False