Merge pull request #3197 from breez/optimize_prune_zombie_channels

Optimize prune zombie channels
This commit is contained in:
Olaoluwa Osuntokun
2019-07-18 20:56:56 -07:00
committed by GitHub
5 changed files with 256 additions and 39 deletions

View File

@@ -316,6 +316,7 @@ type testChannelPolicy struct {
FeeRate lnwire.MilliSatoshi
LastUpdate time.Time
Disabled bool
Direction bool
}
type testChannelEnd struct {
@@ -348,6 +349,9 @@ func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
id = chanID[0]
}
node2Policy := *policy
node2Policy.Direction = !policy.Direction
return &testChannel{
Capacity: capacity,
Node1: &testChannelEnd{
@@ -356,7 +360,7 @@ func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
},
Node2: &testChannelEnd{
Alias: alias2,
testChannelPolicy: policy,
testChannelPolicy: &node2Policy,
},
ChannelID: id,
}
@@ -529,6 +533,9 @@ func createTestGraphFromChannels(testChannels []*testChannel, source string) (
if testChannel.Node1.Disabled {
channelFlags |= lnwire.ChanUpdateDisabled
}
if testChannel.Node1.Direction {
channelFlags |= lnwire.ChanUpdateDirection
}
edgePolicy := &channeldb.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
MessageFlags: msgFlags,
@@ -551,10 +558,13 @@ func createTestGraphFromChannels(testChannels []*testChannel, source string) (
if testChannel.Node2.MaxHTLC != 0 {
msgFlags |= lnwire.ChanUpdateOptionMaxHtlc
}
channelFlags := lnwire.ChanUpdateDirection
channelFlags := lnwire.ChanUpdateChanFlags(0)
if testChannel.Node2.Disabled {
channelFlags |= lnwire.ChanUpdateDisabled
}
if testChannel.Node2.Direction {
channelFlags |= lnwire.ChanUpdateDirection
}
edgePolicy := &channeldb.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
MessageFlags: msgFlags,