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

lightningnetwork / lnd / 13566028875

27 Feb 2025 12:09PM UTC coverage: 49.396% (-9.4%) from 58.748%
13566028875

Pull #9555

github

ellemouton
graph/db: populate the graph cache in Start instead of during construction

In this commit, we move the graph cache population logic out of the
ChannelGraph constructor and into its Start method instead.
Pull Request #9555: graph: extract cache from CRUD [6]

34 of 54 new or added lines in 4 files covered. (62.96%)

27464 existing lines in 436 files now uncovered.

101095 of 204664 relevant lines covered (49.4%)

1.54 hits per line

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

0.0
/watchtower/lookout/mock.go
1
package lookout
2

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

7
        "github.com/btcsuite/btcd/chaincfg/chainhash"
8
        "github.com/btcsuite/btcd/wire"
9
        "github.com/lightningnetwork/lnd/chainntnfs"
10
)
11

12
type MockBackend struct {
13
        mu sync.RWMutex
14

15
        blocks chan *chainntnfs.BlockEpoch
16
        epochs map[chainhash.Hash]*wire.MsgBlock
17
        quit   chan struct{}
18
}
19

UNCOV
20
func NewMockBackend() *MockBackend {
×
UNCOV
21
        return &MockBackend{
×
UNCOV
22
                blocks: make(chan *chainntnfs.BlockEpoch),
×
UNCOV
23
                epochs: make(map[chainhash.Hash]*wire.MsgBlock),
×
UNCOV
24
                quit:   make(chan struct{}),
×
UNCOV
25
        }
×
UNCOV
26
}
×
27

28
func (m *MockBackend) RegisterBlockEpochNtfn(*chainntnfs.BlockEpoch) (
UNCOV
29
        *chainntnfs.BlockEpochEvent, error) {
×
UNCOV
30

×
UNCOV
31
        return &chainntnfs.BlockEpochEvent{
×
UNCOV
32
                Epochs: m.blocks,
×
UNCOV
33
        }, nil
×
UNCOV
34
}
×
35

UNCOV
36
func (m *MockBackend) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock, error) {
×
UNCOV
37
        m.mu.RLock()
×
UNCOV
38
        defer m.mu.RUnlock()
×
UNCOV
39

×
UNCOV
40
        block, ok := m.epochs[*hash]
×
UNCOV
41
        if !ok {
×
42
                return nil, fmt.Errorf("unknown block for hash %x", hash)
×
43
        }
×
44

UNCOV
45
        return block, nil
×
46
}
47

48
func (m *MockBackend) ConnectEpoch(epoch *chainntnfs.BlockEpoch,
UNCOV
49
        block *wire.MsgBlock) {
×
UNCOV
50

×
UNCOV
51
        m.mu.Lock()
×
UNCOV
52
        m.epochs[*epoch.Hash] = block
×
UNCOV
53
        m.mu.Unlock()
×
UNCOV
54

×
UNCOV
55
        select {
×
UNCOV
56
        case m.blocks <- epoch:
×
57
        case <-m.quit:
×
58
        }
59
}
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