mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
chainntnfs: move cache implementation to channeldb
This commit moves the `HeightHintCache` implementation to the `channeldb` package and inverts the dependency relation between `chainntnfs` and `channeldb`. Many packages depend on channeldb for type definitions, interfaces, etc. `chainntnfs` is an example of that. `chainntnfs` defines the `SpendHintCache` and `ConfirmHintCache` interfaces but it also implments them (`HeightHintCache` struct). The implementation uses logic that should not leak from channeldb (ex: bucket paths). This makes our code highly coupled + it would not allow us to use any of these interfaces in a package that is imported by `channeldb` (circular dependency).
This commit is contained in:
@@ -31,7 +31,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func initHintCache(t *testing.T) *chainntnfs.HeightHintCache {
|
||||
func initHintCache(t *testing.T) *channeldb.HeightHintCache {
|
||||
t.Helper()
|
||||
|
||||
db, err := channeldb.Open(t.TempDir())
|
||||
@@ -40,10 +40,10 @@ func initHintCache(t *testing.T) *chainntnfs.HeightHintCache {
|
||||
require.NoError(t, db.Close())
|
||||
})
|
||||
|
||||
testCfg := chainntnfs.CacheConfig{
|
||||
testCfg := channeldb.CacheConfig{
|
||||
QueryDisable: false,
|
||||
}
|
||||
hintCache, err := chainntnfs.NewHeightHintCache(testCfg, db.Backend)
|
||||
hintCache, err := channeldb.NewHeightHintCache(testCfg, db.Backend)
|
||||
require.NoError(t, err, "unable to create hint cache")
|
||||
|
||||
return hintCache
|
||||
|
Reference in New Issue
Block a user