mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
Simplified LevelDB writing.
This commit is contained in:
parent
61cc35fda8
commit
12e0516929
13
leveldb.go
13
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user