cnct: log go to chain reason
This commit adds logging of the reason to go to chain for a channel. This can help users to find out the reason why a channels forced closed. To get all go to chain reasons, an optimization to break early is removed. This optimization was not significant, because the normal flow already examined all htlcs. In the exceptional case where we need to go to chain, it does not weigh up against logging all go to chain reasons.
This commit is contained in:
parent
1fea5b09b2
commit
86eb0a3383
@ -1097,26 +1097,27 @@ func (c *ChannelArbitrator) checkChainActions(height uint32,
|
|||||||
// outgoing HTLC's to decide if we need to go on chain at all.
|
// outgoing HTLC's to decide if we need to go on chain at all.
|
||||||
haveChainActions := false
|
haveChainActions := false
|
||||||
for _, htlc := range c.activeHTLCs.outgoingHTLCs {
|
for _, htlc := range c.activeHTLCs.outgoingHTLCs {
|
||||||
// If any of our HTLC's triggered an on-chain action, then we
|
|
||||||
// can break early.
|
|
||||||
if haveChainActions {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// We'll need to go on-chain for an outgoing HTLC if it was
|
// We'll need to go on-chain for an outgoing HTLC if it was
|
||||||
// never resolved downstream, and it's "close" to timing out.
|
// never resolved downstream, and it's "close" to timing out.
|
||||||
haveChainActions = haveChainActions || c.shouldGoOnChain(
|
toChain := c.shouldGoOnChain(
|
||||||
htlc.RefundTimeout, c.cfg.OutgoingBroadcastDelta,
|
htlc.RefundTimeout, c.cfg.OutgoingBroadcastDelta,
|
||||||
height,
|
height,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
for _, htlc := range c.activeHTLCs.incomingHTLCs {
|
if toChain {
|
||||||
// If any of our HTLC's triggered an on-chain action, then we
|
log.Debugf("ChannelArbitrator(%v): go to chain for "+
|
||||||
// can break early.
|
"outgoing htlc %x: timeout=%v, "+
|
||||||
if haveChainActions {
|
"blocks_until_expiry=%v, broadcast_delta=%v",
|
||||||
break
|
c.cfg.ChanPoint, htlc.RHash[:],
|
||||||
|
htlc.RefundTimeout, htlc.RefundTimeout-height,
|
||||||
|
c.cfg.OutgoingBroadcastDelta,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
haveChainActions = haveChainActions || toChain
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, htlc := range c.activeHTLCs.incomingHTLCs {
|
||||||
// We'll need to go on-chain to pull an incoming HTLC iff we
|
// We'll need to go on-chain to pull an incoming HTLC iff we
|
||||||
// know the pre-image and it's close to timing out. We need to
|
// know the pre-image and it's close to timing out. We need to
|
||||||
// ensure that we claim the funds that our rightfully ours
|
// ensure that we claim the funds that our rightfully ours
|
||||||
@ -1124,10 +1125,23 @@ func (c *ChannelArbitrator) checkChainActions(height uint32,
|
|||||||
if _, ok := c.cfg.PreimageDB.LookupPreimage(htlc.RHash); !ok {
|
if _, ok := c.cfg.PreimageDB.LookupPreimage(htlc.RHash); !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
haveChainActions = haveChainActions || c.shouldGoOnChain(
|
|
||||||
|
toChain := c.shouldGoOnChain(
|
||||||
htlc.RefundTimeout, c.cfg.IncomingBroadcastDelta,
|
htlc.RefundTimeout, c.cfg.IncomingBroadcastDelta,
|
||||||
height,
|
height,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if toChain {
|
||||||
|
log.Debugf("ChannelArbitrator(%v): go to chain for "+
|
||||||
|
"incoming htlc %x: timeout=%v, "+
|
||||||
|
"blocks_until_expiry=%v, broadcast_delta=%v",
|
||||||
|
c.cfg.ChanPoint, htlc.RHash[:],
|
||||||
|
htlc.RefundTimeout, htlc.RefundTimeout-height,
|
||||||
|
c.cfg.IncomingBroadcastDelta,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
haveChainActions = haveChainActions || toChain
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't have any actions to make, then we'll return an empty
|
// If we don't have any actions to make, then we'll return an empty
|
||||||
|
Loading…
Reference in New Issue
Block a user