mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-03 18:22:25 +02:00
router: Optimize pruneZombieChannels.
The current approach iterates all channels in the graph in order to filter those in need. This approach is time consuming, several seconds on my mobile device for ~40,000 channels, while during this time the db is locked in a transaction. The proposed change is to use an existing functionality that utilize the fact that channel update are saved indexed by date. This method enables us to go over only a small subset of the channels, only those that were updated before the "channel expiry" time and further filter them for our need. The same graph that took several seconds to prune was pruned, after the change, in several milliseconds. In addition for testing purposes I added Initiator field to the testChannel structure to reflect the channeldEdgePolicy direction.
This commit is contained in:
@@ -1899,7 +1899,7 @@ func TestPruneChannelGraphStaleEdges(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
freshTimestamp := time.Now()
|
||||
staleTimestamp := time.Time{}
|
||||
staleTimestamp := time.Unix(0, 0)
|
||||
|
||||
// We'll create the following test graph so that only the last channel
|
||||
// is pruned.
|
||||
|
Reference in New Issue
Block a user