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:
positiveblue
2022-11-18 07:23:03 -08:00
parent 681da4b2b5
commit c602ac07e7
10 changed files with 169 additions and 173 deletions

View File

@@ -1836,10 +1836,10 @@ func TestInterfaces(t *testing.T, targetBackEnd string) {
if err != nil {
t.Fatalf("unable to create db: %v", err)
}
testCfg := chainntnfs.CacheConfig{
testCfg := channeldb.CacheConfig{
QueryDisable: false,
}
hintCache, err := chainntnfs.NewHeightHintCache(
hintCache, err := channeldb.NewHeightHintCache(
testCfg, db.Backend,
)
if err != nil {