refactor: move graph related DB code to graph/db from channeldb

This is a pure refactor commit. It moves over all the graph related CRUD
code from `channeldb` to `graph/db`.
This commit is contained in:
Elle Mouton committed 2024-11-28 13:36:13 +02:00
1 parent 9f54ec90aa
commit 74a4b1922b
57 files changed
+512 -299

No files matched your search

+2 -2
View File
@@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/wtxmgr"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/channeldb"
graphdb "github.com/lightningnetwork/lnd/graph/db"
)
// BitcoindFilteredChainView is an implementation of the FilteredChainView
@@ -448,7 +448,7 @@ func (b *BitcoindFilteredChainView) chainFilterer() {
// rewound to ensure all relevant notifications are dispatched.
//
// NOTE: This is part of the FilteredChainView interface.
func (b *BitcoindFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint,
func (b *BitcoindFilteredChainView) UpdateFilter(ops []graphdb.EdgePoint,
updateHeight uint32) error {
newUtxos := make([]wire.OutPoint, len(ops))
+2 -2
View File
@@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/channeldb"
graphdb "github.com/lightningnetwork/lnd/graph/db"
)
// BtcdFilteredChainView is an implementation of the FilteredChainView
@@ -456,7 +456,7 @@ type filterUpdate struct {
// rewound to ensure all relevant notifications are dispatched.
//
// NOTE: This is part of the FilteredChainView interface.
func (b *BtcdFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint,
func (b *BtcdFilteredChainView) UpdateFilter(ops []graphdb.EdgePoint,
updateHeight uint32) error {
newUtxos := make([]wire.OutPoint, len(ops))
+2 -2
View File
@@ -3,7 +3,7 @@ package chainview
import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb"
graphdb "github.com/lightningnetwork/lnd/graph/db"
)
// FilteredChainView represents a subscription to a certain subset of the
@@ -43,7 +43,7 @@ type FilteredChainView interface {
// relevant notifications are dispatched, meaning blocks with a height
// lower than the best known height might be sent over the
// FilteredBlocks() channel.
UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
UpdateFilter(ops []graphdb.EdgePoint, updateHeight uint32) error
// FilterBlock takes a block hash, and returns a FilteredBlocks which
// is the result of applying the current registered UTXO sub-set on the
+4 -4
View File
@@ -21,7 +21,7 @@ import (
_ "github.com/btcsuite/btcwallet/walletdb/bdb" // Required to register the boltdb walletdb implementation.
"github.com/lightninglabs/neutrino"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/channeldb"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lntest/unittest"
"github.com/lightningnetwork/lnd/lntest/wait"
@@ -218,7 +218,7 @@ func testFilterBlockNotifications(node *rpctest.Harness,
require.NoError(t, err, "unable to get current height")
// Now we'll add both outpoints to the current filter.
filter := []channeldb.EdgePoint{
filter := []graphdb.EdgePoint{
{FundingPkScript: targetScript, OutPoint: *outPoint1},
{FundingPkScript: targetScript, OutPoint: *outPoint2},
}
@@ -328,7 +328,7 @@ func testUpdateFilterBackTrack(node *rpctest.Harness,
// After the block has been mined+notified we'll update the filter with
// a _prior_ height so a "rewind" occurs.
filter := []channeldb.EdgePoint{
filter := []graphdb.EdgePoint{
{FundingPkScript: testScript, OutPoint: *outPoint},
}
err = chainView.UpdateFilter(filter, uint32(currentHeight))
@@ -417,7 +417,7 @@ func testFilterSingleBlock(node *rpctest.Harness, chainView FilteredChainView,
// Now we'll manually trigger filtering the block generated above.
// First, we'll add the two outpoints to our filter.
filter := []channeldb.EdgePoint{
filter := []graphdb.EdgePoint{
{FundingPkScript: testScript, OutPoint: *outPoint1},
{FundingPkScript: testScript, OutPoint: *outPoint2},
}
+2 -2
View File
@@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightninglabs/neutrino"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/channeldb"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/lntypes"
)
@@ -320,7 +320,7 @@ func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredB
// rewound to ensure all relevant notifications are dispatched.
//
// NOTE: This is part of the FilteredChainView interface.
func (c *CfFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint,
func (c *CfFilteredChainView) UpdateFilter(ops []graphdb.EdgePoint,
updateHeight uint32) error {
log.Tracef("Updating chain filter with new UTXO's: %v", ops)