• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 15951470896

29 Jun 2025 04:23AM UTC coverage: 67.594% (-0.01%) from 67.606%
15951470896

Pull #9751

github

web-flow
Merge 599d9b051 into 6290edf14
Pull Request #9751: multi: update Go to 1.23.10 and update some packages

135088 of 199851 relevant lines covered (67.59%)

21909.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/batch/kvdb.go
1
package batch
2

3
import (
4
        "context"
5
        "fmt"
6

7
        "github.com/lightningnetwork/lnd/kvdb"
8
        "github.com/lightningnetwork/lnd/sqldb"
9
)
10

11
// BoltBatcher is a bbolt implementation of the sqldb.BatchedTx interface.
12
type BoltBatcher[Q any] struct {
13
        db kvdb.Backend
14
}
15

16
// NewBoltBackend creates a new BoltBackend instance.
17
func NewBoltBackend[Q any](db kvdb.Backend) *BoltBatcher[Q] {
344✔
18
        return &BoltBatcher[Q]{db: db}
344✔
19
}
344✔
20

21
// ExecTx will execute the passed txBody, operating upon generic
22
// parameter Q (usually a storage interface) in a single transaction.
23
//
24
// NOTE: This is part of the sqldb.BatchedTx interface.
25
func (t *BoltBatcher[Q]) ExecTx(_ context.Context, opts sqldb.TxOptions,
26
        txBody func(Q) error, reset func()) error {
5,308✔
27

5,308✔
28
        if opts.ReadOnly() {
5,410✔
29
                return kvdb.View(t.db, func(tx kvdb.RTx) error {
204✔
30
                        q, ok := any(tx).(Q)
102✔
31
                        if !ok {
102✔
32
                                return fmt.Errorf("unable to cast tx(%T) "+
×
33
                                        "into the type expected by the "+
×
34
                                        "BoltBatcher(%T)", tx, t)
×
35
                        }
×
36

37
                        return txBody(q)
102✔
38
                }, reset)
39
        }
40

41
        return kvdb.Update(t.db, func(tx kvdb.RwTx) error {
10,412✔
42
                q, ok := any(tx).(Q)
5,206✔
43
                if !ok {
5,206✔
44
                        return fmt.Errorf("unable to cast tx(%T) into the "+
×
45
                                "type expected by the BoltBatcher(%T)", tx, t)
×
46
                }
×
47

48
                return txBody(q)
5,206✔
49
        }, reset)
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc