This commit is contained in:
Mechiel Lukkien
2023-01-30 14:27:06 +01:00
commit cb229cb6cf
1256 changed files with 491723 additions and 0 deletions

24
store/transact.go Normal file
View File

@ -0,0 +1,24 @@
package store
import (
"github.com/mjl-/bstore"
)
// todo: get rid of this. it's a bad idea to indiscriminately turn all panics into an error.
func extransact(db *bstore.DB, write bool, fn func(tx *bstore.Tx) error) (rerr error) {
defer func() {
x := recover()
if x == nil {
return
}
if err, ok := x.(error); ok {
rerr = err
} else {
panic(x)
}
}()
if write {
return db.Write(fn)
}
return db.Read(fn)
}