Struct grin_store::lmdb::Store
source · pub struct Store { /* private fields */ }
Expand description
LMDB-backed store facilitating data access and serialization. All writes are done through a Batch abstraction providing atomicity.
Implementations§
source§impl Store
impl Store
sourcepub fn new(
root_path: &str,
env_name: Option<&str>,
db_name: Option<&str>,
max_readers: Option<u32>
) -> Result<Store, Error>
pub fn new( root_path: &str, env_name: Option<&str>, db_name: Option<&str>, max_readers: Option<u32> ) -> Result<Store, Error>
Create a new LMDB env under the provided directory. By default creates an environment named “lmdb”. Be aware of transactional semantics in lmdb (transactions are per environment, not per database).
sourcepub fn with_version(&self, version: ProtocolVersion) -> Store
pub fn with_version(&self, version: ProtocolVersion) -> Store
Construct a new store using a specific protocol version. Permits access to the db with legacy protocol versions for db migrations.
sourcepub fn protocol_version(&self) -> ProtocolVersion
pub fn protocol_version(&self) -> ProtocolVersion
Protocol version for the store.
sourcepub fn needs_resize(&self) -> Result<bool, Error>
pub fn needs_resize(&self) -> Result<bool, Error>
Determines whether the environment needs a resize based on a simple percentage threshold
sourcepub fn do_resize(&self) -> Result<(), Error>
pub fn do_resize(&self) -> Result<(), Error>
Increments the database size by as many ALLOC_CHUNK_SIZES to give a minimum threshold of free space
sourcepub fn get_with<F, T>(
&self,
key: &[u8],
access: &ConstAccessor<'_>,
db: &Database<'_>,
deserialize: F
) -> Result<Option<T>, Error>
pub fn get_with<F, T>( &self, key: &[u8], access: &ConstAccessor<'_>, db: &Database<'_>, deserialize: F ) -> Result<Option<T>, Error>
Gets a value from the db, provided its key. Deserializes the retrieved data using the provided function.
sourcepub fn get_ser<T: Readable>(
&self,
key: &[u8],
deser_mode: Option<DeserializationMode>
) -> Result<Option<T>, Error>
pub fn get_ser<T: Readable>( &self, key: &[u8], deser_mode: Option<DeserializationMode> ) -> Result<Option<T>, Error>
Gets a Readable
value from the db, provided its key.
Note: Creates a new read transaction so will not see any uncommitted data.