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