mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
contractcourt: add verbose logging in resolvers
We now put the outpoint in the resolvers's logging so it's easier to debug.
This commit is contained in:
parent
0bab6b3419
commit
1f2cfc6a60
@ -2,6 +2,7 @@ package contractcourt
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
@ -71,7 +72,7 @@ func newAnchorResolver(anchorSignDescriptor input.SignDescriptor,
|
||||
currentReport: report,
|
||||
}
|
||||
|
||||
r.initLogger(r)
|
||||
r.initLogger(fmt.Sprintf("%T(%v)", r, r.anchor))
|
||||
|
||||
return r
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package contractcourt
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
@ -32,7 +33,7 @@ func newBreachResolver(resCfg ResolverConfig) *breachResolver {
|
||||
replyChan: make(chan struct{}),
|
||||
}
|
||||
|
||||
r.initLogger(r)
|
||||
r.initLogger(fmt.Sprintf("%T(%v)", r, r.ChanPoint))
|
||||
|
||||
return r
|
||||
}
|
||||
@ -114,7 +115,7 @@ func newBreachResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b.initLogger(b)
|
||||
b.initLogger(fmt.Sprintf("%T(%v)", b, b.ChanPoint))
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func newCommitSweepResolver(res lnwallet.CommitOutputResolution,
|
||||
chanPoint: chanPoint,
|
||||
}
|
||||
|
||||
r.initLogger(r)
|
||||
r.initLogger(fmt.Sprintf("%T(%v)", r, r.commitResolution.SelfOutPoint))
|
||||
r.initReport()
|
||||
|
||||
return r
|
||||
@ -484,7 +484,7 @@ func newCommitSweepResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
||||
// removed this, but keep in mind that this data may still be present in
|
||||
// the database.
|
||||
|
||||
c.initLogger(c)
|
||||
c.initLogger(fmt.Sprintf("%T(%v)", c, c.commitResolution.SelfOutPoint))
|
||||
c.initReport()
|
||||
|
||||
return c, nil
|
||||
|
@ -120,8 +120,10 @@ func newContractResolverKit(cfg ResolverConfig) *contractResolverKit {
|
||||
}
|
||||
|
||||
// initLogger initializes the resolver-specific logger.
|
||||
func (r *contractResolverKit) initLogger(resolver ContractResolver) {
|
||||
logPrefix := fmt.Sprintf("%T(%v):", resolver, r.ChanPoint)
|
||||
func (r *contractResolverKit) initLogger(prefix string) {
|
||||
logPrefix := fmt.Sprintf("ChannelArbitrator(%v): %s:", r.ChanPoint,
|
||||
prefix)
|
||||
|
||||
r.log = log.WithPrefix(logPrefix)
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package contractcourt
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
@ -81,27 +82,30 @@ func newSuccessResolver(res lnwallet.IncomingHtlcResolution,
|
||||
}
|
||||
|
||||
h.initReport()
|
||||
h.initLogger(fmt.Sprintf("%T(%v)", h, h.outpoint()))
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
// outpoint returns the outpoint of the HTLC output we're attempting to sweep.
|
||||
func (h *htlcSuccessResolver) outpoint() wire.OutPoint {
|
||||
// The primary key for this resolver will be the outpoint of the HTLC
|
||||
// on the commitment transaction itself. If this is our commitment,
|
||||
// then the output can be found within the signed success tx,
|
||||
// otherwise, it's just the ClaimOutpoint.
|
||||
if h.htlcResolution.SignedSuccessTx != nil {
|
||||
return h.htlcResolution.SignedSuccessTx.TxIn[0].PreviousOutPoint
|
||||
}
|
||||
|
||||
return h.htlcResolution.ClaimOutpoint
|
||||
}
|
||||
|
||||
// ResolverKey returns an identifier which should be globally unique for this
|
||||
// particular resolver within the chain the original contract resides within.
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (h *htlcSuccessResolver) ResolverKey() []byte {
|
||||
// The primary key for this resolver will be the outpoint of the HTLC
|
||||
// on the commitment transaction itself. If this is our commitment,
|
||||
// then the output can be found within the signed success tx,
|
||||
// otherwise, it's just the ClaimOutpoint.
|
||||
var op wire.OutPoint
|
||||
if h.htlcResolution.SignedSuccessTx != nil {
|
||||
op = h.htlcResolution.SignedSuccessTx.TxIn[0].PreviousOutPoint
|
||||
} else {
|
||||
op = h.htlcResolution.ClaimOutpoint
|
||||
}
|
||||
|
||||
key := newResolverID(op)
|
||||
key := newResolverID(h.outpoint())
|
||||
return key[:]
|
||||
}
|
||||
|
||||
@ -679,6 +683,7 @@ func newSuccessResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
||||
}
|
||||
|
||||
h.initReport()
|
||||
h.initLogger(fmt.Sprintf("%T(%v)", h, h.outpoint()))
|
||||
|
||||
return h, nil
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ func newTimeoutResolver(res lnwallet.OutgoingHtlcResolution,
|
||||
}
|
||||
|
||||
h.initReport()
|
||||
h.initLogger(fmt.Sprintf("%T(%v)", h, h.outpoint()))
|
||||
|
||||
return h
|
||||
}
|
||||
@ -93,23 +94,25 @@ func (h *htlcTimeoutResolver) isTaproot() bool {
|
||||
)
|
||||
}
|
||||
|
||||
// outpoint returns the outpoint of the HTLC output we're attempting to sweep.
|
||||
func (h *htlcTimeoutResolver) outpoint() wire.OutPoint {
|
||||
// The primary key for this resolver will be the outpoint of the HTLC
|
||||
// on the commitment transaction itself. If this is our commitment,
|
||||
// then the output can be found within the signed timeout tx,
|
||||
// otherwise, it's just the ClaimOutpoint.
|
||||
if h.htlcResolution.SignedTimeoutTx != nil {
|
||||
return h.htlcResolution.SignedTimeoutTx.TxIn[0].PreviousOutPoint
|
||||
}
|
||||
|
||||
return h.htlcResolution.ClaimOutpoint
|
||||
}
|
||||
|
||||
// ResolverKey returns an identifier which should be globally unique for this
|
||||
// particular resolver within the chain the original contract resides within.
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (h *htlcTimeoutResolver) ResolverKey() []byte {
|
||||
// The primary key for this resolver will be the outpoint of the HTLC
|
||||
// on the commitment transaction itself. If this is our commitment,
|
||||
// then the output can be found within the signed timeout tx,
|
||||
// otherwise, it's just the ClaimOutpoint.
|
||||
var op wire.OutPoint
|
||||
if h.htlcResolution.SignedTimeoutTx != nil {
|
||||
op = h.htlcResolution.SignedTimeoutTx.TxIn[0].PreviousOutPoint
|
||||
} else {
|
||||
op = h.htlcResolution.ClaimOutpoint
|
||||
}
|
||||
|
||||
key := newResolverID(op)
|
||||
key := newResolverID(h.outpoint())
|
||||
return key[:]
|
||||
}
|
||||
|
||||
@ -1038,6 +1041,7 @@ func newTimeoutResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
||||
}
|
||||
|
||||
h.initReport()
|
||||
h.initLogger(fmt.Sprintf("%T(%v)", h, h.outpoint()))
|
||||
|
||||
return h, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user