From ec0fb9c537ad2a71c0ca0d20c390fedc06ebc539 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 17 Jul 2018 19:12:28 -0700 Subject: [PATCH] routing/chainview: modify the UpdateFilter method to take a channeldb.EdgePoint In this commit, we update the existing UpdateFilter method to take the new channeldb.EdgePoint struct in place of the prior wire.OutPoint. We must do this as the caller now typically has this type due to the preparation to enable lnd to be able to be compatible with the new neutrino protocol. --- routing/chainview/interface.go | 3 ++- routing/chainview/interface_test.go | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/routing/chainview/interface.go b/routing/chainview/interface.go index 036d90c0..cfa9fccf 100644 --- a/routing/chainview/interface.go +++ b/routing/chainview/interface.go @@ -3,6 +3,7 @@ package chainview import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + "github.com/lightningnetwork/lnd/channeldb" ) // FilteredChainView represents a subscription to a certain subset of the @@ -42,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 []wire.OutPoint, updateHeight uint32) error + UpdateFilter(ops []channeldb.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 diff --git a/routing/chainview/interface_test.go b/routing/chainview/interface_test.go index c563434a..5ab054df 100644 --- a/routing/chainview/interface_test.go +++ b/routing/chainview/interface_test.go @@ -21,6 +21,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" "github.com/lightninglabs/neutrino" + "github.com/lightningnetwork/lnd/channeldb" "github.com/ltcsuite/ltcd/btcjson" "github.com/btcsuite/btcwallet/walletdb" @@ -238,8 +239,11 @@ func testFilterBlockNotifications(node *rpctest.Harness, t.Fatalf("unable to get current height: %v", err) } - // Now we'll add both output to the current filter. - filter := []wire.OutPoint{*outPoint1, *outPoint2} + // Now we'll add both outpoints to the current filter. + filter := []channeldb.EdgePoint{ + {targetScript, *outPoint1}, + {targetScript, *outPoint2}, + } err = chainView.UpdateFilter(filter, uint32(currentHeight)) if err != nil { t.Fatalf("unable to update filter: %v", err) @@ -382,8 +386,9 @@ 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 := []wire.OutPoint{*outPoint} - + filter := []channeldb.EdgePoint{ + {testScript, *outPoint}, + } err = chainView.UpdateFilter(filter, uint32(currentHeight)) if err != nil { t.Fatalf("unable to update filter: %v", err) @@ -496,7 +501,10 @@ 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 := []wire.OutPoint{*outPoint1, *outPoint2} + filter := []channeldb.EdgePoint{ + {testScript, *outPoint1}, + {testScript, *outPoint2}, + } err = chainView.UpdateFilter(filter, uint32(currentHeight)) if err != nil { t.Fatalf("unable to update filter: %v", err)