Skip to content

Commit 7e08322

Browse files
committed
chainntfns: rename to CacheConfig and QueryDisabled
1 parent b907035 commit 7e08322

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

chainntnfs/bitcoindnotify/bitcoind_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func initHintCache(t *testing.T) *chainntnfs.HeightHintCache {
4040
if err != nil {
4141
t.Fatalf("unable to create db: %v", err)
4242
}
43-
testCfg := chainntnfs.Config{
44-
HeightHintCacheQueryDisable: false,
43+
testCfg := chainntnfs.CacheConfig{
44+
QueryDisable: false,
4545
}
4646
hintCache, err := chainntnfs.NewHeightHintCache(testCfg, db)
4747
if err != nil {

chainntnfs/btcdnotify/btcd_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func initHintCache(t *testing.T) *chainntnfs.HeightHintCache {
3838
if err != nil {
3939
t.Fatalf("unable to create db: %v", err)
4040
}
41-
testCfg := chainntnfs.Config{
42-
HeightHintCacheQueryDisable: false,
41+
testCfg := chainntnfs.CacheConfig{
42+
QueryDisable: false,
4343
}
4444
hintCache, err := chainntnfs.NewHeightHintCache(testCfg, db)
4545
if err != nil {

chainntnfs/height_hint_cache.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ var (
3535
ErrConfirmHintNotFound = errors.New("confirm hint not found")
3636
)
3737

38-
// Config contains the HeightHintCache configuration
39-
type Config struct {
40-
// HeightHintCacheQueryDisable prevents reliance on the Height Hint Cache.
41-
// This is necessary to recover from an edge case when the height
42-
// recorded in the cache is higher than the actual height of a spend,
43-
// causing a channel to become "stuck" in a pending close state.
44-
HeightHintCacheQueryDisable bool
38+
// CacheConfig contains the HeightHintCache configuration
39+
type CacheConfig struct {
40+
// QueryDisable prevents reliance on the Height Hint Cache. This is
41+
// necessary to recover from an edge case when the height recorded in
42+
// the cache is higher than the actual height of a spend, causing a
43+
// channel to become "stuck" in a pending close state.
44+
QueryDisable bool
4545
}
4646

4747
// SpendHintCache is an interface whose duty is to cache spend hints for
@@ -83,7 +83,7 @@ type ConfirmHintCache interface {
8383
// ConfirmHintCache interfaces backed by a channeldb DB instance where the hints
8484
// will be stored.
8585
type HeightHintCache struct {
86-
cfg Config
86+
cfg CacheConfig
8787
db *channeldb.DB
8888
}
8989

@@ -93,7 +93,7 @@ var _ SpendHintCache = (*HeightHintCache)(nil)
9393
var _ ConfirmHintCache = (*HeightHintCache)(nil)
9494

9595
// NewHeightHintCache returns a new height hint cache backed by a database.
96-
func NewHeightHintCache(cfg Config, db *channeldb.DB) (*HeightHintCache, error) {
96+
func NewHeightHintCache(cfg CacheConfig, db *channeldb.DB) (*HeightHintCache, error) {
9797
cache := &HeightHintCache{cfg, db}
9898
if err := cache.initBuckets(); err != nil {
9999
return nil, err
@@ -158,8 +158,8 @@ func (c *HeightHintCache) CommitSpendHint(height uint32,
158158
// cache for the outpoint.
159159
func (c *HeightHintCache) QuerySpendHint(spendRequest SpendRequest) (uint32, error) {
160160
var hint uint32
161-
if c.cfg.HeightHintCacheQueryDisable {
162161
Log.Debugf("Ignoring spend height hint for %v (height hint cache query disabled)", spendRequest)
162+
if c.cfg.QueryDisable {
163163
return 0, nil
164164
}
165165
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
@@ -256,8 +256,8 @@ func (c *HeightHintCache) CommitConfirmHint(height uint32,
256256
// the cache for the transaction hash.
257257
func (c *HeightHintCache) QueryConfirmHint(confRequest ConfRequest) (uint32, error) {
258258
var hint uint32
259-
if c.cfg.HeightHintCacheQueryDisable {
260259
Log.Debugf("Ignoring confirmation height hint for %v (height hint cache query disabled)", confRequest)
260+
if c.cfg.QueryDisable {
261261
return 0, nil
262262
}
263263
err := kvdb.View(c.db, func(tx kvdb.RTx) error {

chainntnfs/height_hint_cache_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ func initHintCache(t *testing.T) *HeightHintCache {
2121
if err != nil {
2222
t.Fatalf("unable to create db: %v", err)
2323
}
24-
testCfg := Config{
25-
HeightHintCacheQueryDisable: false,
24+
testCfg := CacheConfig{
25+
QueryDisable: false,
2626
}
2727
hintCache, err := NewHeightHintCache(testCfg, db)
2828
if err != nil {

chainntnfs/interface_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1911,8 +1911,8 @@ func TestInterfaces(t *testing.T) {
19111911
if err != nil {
19121912
t.Fatalf("unable to create db: %v", err)
19131913
}
1914-
testCfg := chainntnfs.Config{
1915-
HeightHintCacheQueryDisable: false,
1914+
testCfg := chainntnfs.CacheConfig{
1915+
QueryDisable: false,
19161916
}
19171917
hintCache, err := chainntnfs.NewHeightHintCache(testCfg, db)
19181918
if err != nil {

chainregistry.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ func newChainControlFromConfig(cfg *Config, chanDB *channeldb.DB,
219219

220220
var err error
221221

222-
heightHintCacheConfig := chainntnfs.Config{
223-
HeightHintCacheQueryDisable: cfg.HeightHintCacheQueryDisable,
222+
heightHintCacheConfig := chainntnfs.CacheConfig{
223+
QueryDisable: cfg.HeightHintCacheQueryDisable,
224224
}
225225
if cfg.HeightHintCacheQueryDisable {
226226
ltndLog.Infof("Height Hint Cache Queries disabled")

lnwallet/interface_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3014,8 +3014,8 @@ func TestLightningWallet(t *testing.T) {
30143014
if err != nil {
30153015
t.Fatalf("unable to create db: %v", err)
30163016
}
3017-
testCfg := chainntnfs.Config{
3018-
HeightHintCacheQueryDisable: false,
3017+
testCfg := chainntnfs.CacheConfig{
3018+
QueryDisable: false,
30193019
}
30203020
hintCache, err := chainntnfs.NewHeightHintCache(testCfg, db)
30213021
if err != nil {

0 commit comments

Comments
 (0)