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:
6 files changed
+44
-31
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user