diff --git a/channeldb/db.go b/channeldb/db.go index 564dbb7b..32851035 100644 --- a/channeldb/db.go +++ b/channeldb/db.go @@ -6,7 +6,6 @@ import ( "fmt" "net" "os" - "time" "github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/wire" @@ -974,13 +973,6 @@ type ChannelShell struct { // well. This method is idempotent, so repeated calls with the same set of // channel shells won't modify the database after the initial call. func (d *DB) RestoreChannelShells(channelShells ...*ChannelShell) error { - chanGraph := d.ChannelGraph() - - // TODO(conner): find way to do this w/o accessing internal members? - chanGraph.cacheMu.Lock() - defer chanGraph.cacheMu.Unlock() - - var chansRestored []uint64 err := kvdb.Update(d, func(tx kvdb.RwTx) error { for _, channelShell := range channelShells { channel := channelShell.Chan @@ -1002,72 +994,6 @@ func (d *DB) RestoreChannelShells(channelShells ...*ChannelShell) error { if err != nil { return err } - - // Next, we'll create an active edge in the graph - // database for this channel in order to restore our - // partial view of the network. - // - // TODO(roasbeef): if we restore *after* the channel - // has been closed on chain, then need to inform the - // router that it should try and prune these values as - // we can detect them - edgeInfo := ChannelEdgeInfo{ - ChannelID: channel.ShortChannelID.ToUint64(), - ChainHash: channel.ChainHash, - ChannelPoint: channel.FundingOutpoint, - Capacity: channel.Capacity, - } - - nodes := tx.ReadWriteBucket(nodeBucket) - if nodes == nil { - return ErrGraphNotFound - } - selfNode, err := chanGraph.sourceNode(nodes) - if err != nil { - return err - } - - // Depending on which pub key is smaller, we'll assign - // our roles as "node1" and "node2". - chanPeer := channel.IdentityPub.SerializeCompressed() - selfIsSmaller := bytes.Compare( - selfNode.PubKeyBytes[:], chanPeer, - ) == -1 - if selfIsSmaller { - copy(edgeInfo.NodeKey1Bytes[:], selfNode.PubKeyBytes[:]) - copy(edgeInfo.NodeKey2Bytes[:], chanPeer) - } else { - copy(edgeInfo.NodeKey1Bytes[:], chanPeer) - copy(edgeInfo.NodeKey2Bytes[:], selfNode.PubKeyBytes[:]) - } - - // With the edge info shell constructed, we'll now add - // it to the graph. - err = chanGraph.addChannelEdge(tx, &edgeInfo) - if err != nil && err != ErrEdgeAlreadyExist { - return err - } - - // Similarly, we'll construct a channel edge shell and - // add that itself to the graph. - chanEdge := ChannelEdgePolicy{ - ChannelID: edgeInfo.ChannelID, - LastUpdate: time.Now(), - } - - // If their pubkey is larger, then we'll flip the - // direction bit to indicate that us, the "second" node - // is updating their policy. - if !selfIsSmaller { - chanEdge.ChannelFlags |= lnwire.ChanUpdateDirection - } - - _, err = updateEdgePolicy(tx, &chanEdge) - if err != nil { - return err - } - - chansRestored = append(chansRestored, edgeInfo.ChannelID) } return nil @@ -1076,11 +1002,6 @@ func (d *DB) RestoreChannelShells(channelShells ...*ChannelShell) error { return err } - for _, chanid := range chansRestored { - chanGraph.rejectCache.remove(chanid) - chanGraph.chanCache.remove(chanid) - } - return nil } diff --git a/channeldb/db_test.go b/channeldb/db_test.go index c97d23c0..e5c57c1d 100644 --- a/channeldb/db_test.go +++ b/channeldb/db_test.go @@ -365,19 +365,6 @@ func TestRestoreChannelShells(t *testing.T) { t.Fatalf("unable to gen channel shell: %v", err) } - graph := cdb.ChannelGraph() - - // Before we can restore the channel, we'll need to make a source node - // in the graph as the channel edge we create will need to have a - // origin. - testNode, err := createTestVertex(cdb) - if err != nil { - t.Fatalf("unable to create test node: %v", err) - } - if err := graph.SetSourceNode(testNode); err != nil { - t.Fatalf("unable to set source node: %v", err) - } - // With the channel shell constructed, we'll now insert it into the // database with the restoration method. if err := cdb.RestoreChannelShells(channelShell); err != nil { @@ -449,25 +436,6 @@ func TestRestoreChannelShells(t *testing.T) { t.Fatalf("addr mismach: expected %v, got %v", linkNode.Addresses, channelShell.NodeAddrs) } - - // Finally, we'll ensure that the edge for the channel was properly - // inserted. - chanInfos, err := graph.FetchChanInfos( - []uint64{channelShell.Chan.ShortChannelID.ToUint64()}, - ) - if err != nil { - t.Fatalf("unable to find edges: %v", err) - } - - if len(chanInfos) != 1 { - t.Fatalf("wrong amount of chan infos: expected %v got %v", - len(chanInfos), 1) - } - - // We should only find a single edge. - if chanInfos[0].Policy1 != nil && chanInfos[0].Policy2 != nil { - t.Fatalf("only a single edge should be inserted: %v", err) - } } // TestAbandonChannel tests that the AbandonChannel method is able to properly diff --git a/lntest/itest/log_error_whitelist.txt b/lntest/itest/log_error_whitelist.txt index 6541cab0..986d098d 100644 --- a/lntest/itest/log_error_whitelist.txt +++ b/lntest/itest/log_error_whitelist.txt @@ -70,6 +70,7 @@