lmdb: use a different goroutine for each read txn.

This commit is contained in:
fiatjaf
2023-12-07 11:44:20 -03:00
parent 3777e2f8f6
commit c09105f54b

View File

@@ -38,8 +38,9 @@ func (b *LMDBBackend) QueryEvents(ctx context.Context, filter nostr.Filter) (cha
go func() {
defer close(ch)
err := b.lmdbEnv.View(func(txn *lmdb.Txn) error {
for _, q := range queries {
q := q
go b.lmdbEnv.View(func(txn *lmdb.Txn) error {
txn.RawRead = true
defer close(q.results)
@@ -111,9 +112,9 @@ func (b *LMDBBackend) QueryEvents(ctx context.Context, filter nostr.Filter) (cha
// move one back (we'll look into k and v and err in the next iteration)
k, idx, iterr = cursor.Get(nil, nil, lmdb.Prev)
}
}
return nil
})
}
if err != nil {
log.Printf("lmdb: error on cursor iteration: %v\n", err)
}