contractcourt: add String to CommitSet for logging
This commit is contained in:
2 files changed
+32
-3
No files matched your search
@@ -131,6 +131,35 @@ func (c *CommitSet) toActiveHTLCSets() map[HtlcSetKey]htlcSet {
|
|||||||
return htlcSets
|
return htlcSets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String return a human-readable representation of the CommitSet.
|
||||||
|
func (c *CommitSet) String() string {
|
||||||
|
if c == nil {
|
||||||
|
return "nil"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a descriptive string for the ConfCommitKey.
|
||||||
|
commitKey := "none"
|
||||||
|
c.ConfCommitKey.WhenSome(func(k HtlcSetKey) {
|
||||||
|
commitKey = k.String()
|
||||||
|
})
|
||||||
|
|
||||||
|
// Create a map to hold all the htlcs.
|
||||||
|
htlcSet := make(map[string]string)
|
||||||
|
for k, htlcs := range c.HtlcSets {
|
||||||
|
// Create a map for this particular set.
|
||||||
|
desc := make([]string, len(htlcs))
|
||||||
|
for i, htlc := range htlcs {
|
||||||
|
desc[i] = fmt.Sprintf("%x", htlc.RHash)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the description to the set key.
|
||||||
|
htlcSet[k.String()] = fmt.Sprintf("count: %v, htlcs=%v",
|
||||||
|
len(htlcs), desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("ConfCommitKey=%v, HtlcSets=%v", commitKey, htlcSet)
|
||||||
|
}
|
||||||
|
|
||||||
// ChainEventSubscription is a struct that houses a subscription to be notified
|
// ChainEventSubscription is a struct that houses a subscription to be notified
|
||||||
// for any on-chain events related to a channel. There are three types of
|
// for any on-chain events related to a channel. There are three types of
|
||||||
// possible on-chain events: a cooperative channel closure, a unilateral
|
// possible on-chain events: a cooperative channel closure, a unilateral
|
||||||
|
|||||||
@@ -947,9 +947,9 @@ func (c *ChannelArbitrator) stateStep(
|
|||||||
// If we're in the default state, then we'll check our set of actions
|
// If we're in the default state, then we'll check our set of actions
|
||||||
// to see if while we were down, conditions have changed.
|
// to see if while we were down, conditions have changed.
|
||||||
case StateDefault:
|
case StateDefault:
|
||||||
log.Debugf("ChannelArbitrator(%v): new block (height=%v) "+
|
log.Debugf("ChannelArbitrator(%v): examining active HTLCs in "+
|
||||||
"examining active HTLC's", c.cfg.ChanPoint,
|
"block %v, confCommitSet: %v", c.cfg.ChanPoint,
|
||||||
triggerHeight)
|
triggerHeight, lnutils.LogClosure(confCommitSet.String))
|
||||||
|
|
||||||
// As a new block has been connected to the end of the main
|
// As a new block has been connected to the end of the main
|
||||||
// chain, we'll check to see if we need to make any on-chain
|
// chain, we'll check to see if we need to make any on-chain
|
||||||
|
|||||||
Reference in new issue
Block a user