Simplified LevelDB writing.

This commit is contained in:
Sascha L. Teichmann 2014-08-04 15:28:01 +02:00
parent 61cc35fda8
commit 12e0516929

View File

@ -74,10 +74,8 @@ func (ldb *LevelDBBackend) Store(hash, key, value []byte) (exists bool, err erro
} }
wo := leveldb.NewWriteOptions() wo := leveldb.NewWriteOptions()
defer wo.Close() err = ldb.db.Put(wo, key, value)
if err = ldb.db.Put(wo, key, value); err != nil { wo.Close()
return
}
return return
} }
@ -87,10 +85,11 @@ func (ldb *LevelDBBackend) BeginTransaction() error {
return nil return nil
} }
func (ldb *LevelDBBackend) CommitTransaction() error { func (ldb *LevelDBBackend) CommitTransaction() (err error) {
tx := ldb.tx tx := ldb.tx
ldb.tx = nil ldb.tx = nil
wo := leveldb.NewWriteOptions() wo := leveldb.NewWriteOptions()
defer wo.Close() err = ldb.db.Write(wo, tx)
return ldb.db.Write(wo, tx) wo.Close()
return
} }