/// Insert a pool object under the given type/height/id key.
Insert a pool object under the given type/height/id key.
Insert a pool object under the given type / height / id key .
fn tx_insert<'a, PoolObject>(
        &self,
        tx: &mut RwTransaction<'a>,
        key: &ArtifactKey,
        value: PoolObject,
    ) -> lmdb::Result<()>
    where
        Artifact: PoolArtifact<ObjectType = PoolObject>,
    {
        // update index db first, because requiring NO_DUP_DATA may lead to
        // error when dup is detected. Insertion can be skipped in this case.
        let index_db = self.get_index_db(&key.type_key);
        tx.put(
            index_db,
            &key.height_key,
            &key.id_key,
            WriteFlags::NO_DUP_DATA,
        )?;
        // update meta
        let meta = self
            .get_meta(tx, &key.type_key)
            .map(|meta| Meta {
                min: meta.min.min(key.height_key),
                max: meta.max.max(key.height_key),
            })
            .unwrap_or(Meta {
                min: key.height_key,
                max: key.height_key,
            });
        self.update_meta(tx, &key.type_key, &meta)?;
        // update artifacts (ignore KeyExists)
        Artifact::save(&key.id_key, value, self.artifacts, tx, &self.log)
    }
fn tx_insert < ' a , PoolObject > ( & self , tx : & mut RwTransaction < ' a > , key : & ArtifactKey , value : PoolObject , ) -> lmdb :: Result < ( ) > where Artifact : PoolArtifact < ObjectType = PoolObject > , { // update index db first, because requiring NO_DUP_DATA may lead to // error when dup is detected. Insertion can be skipped in this case. let index_db = self . get_index_db ( & key . type_key ) ; tx . put ( index_db , & key . height_key , & key . id_key , WriteFlags :: NO_DUP_DATA , ) ? ; // update meta let meta = self . get_meta ( tx , & key . type_key ) . map ( | meta | Meta { min : meta . min . min ( key . height_key ) , max : meta . max . max ( key . height_key ) , } ) . unwrap_or ( Meta { min : key . height_key , max : key . height_key , } ) ; self . update_meta ( tx , & key . type_key , & meta ) ? ; // update artifacts (ignore KeyExists) Artifact :: save ( & key . id_key , value , self . artifacts , tx , & self . log ) }
Insert a pool object under the given type/height/id key.
Insert a pool object under the given type / height / id key .
&self
tx
&mut RwTransaction<'a>
key
&ArtifactKey
value
PoolObject