contractcourt/[incoming|outgoing]_contest_resolver: make inner resolver pointer
To make the linter happy, make a pointer to the inner resolver. Otherwise the linter would complain with copylocks: literal copies lock value since we'll add a mutex to the resolver in following commits.
This commit is contained in:
parent
4da2b290f9
commit
9b08ef6d4e
@ -271,13 +271,13 @@ func assertResolversEqual(t *testing.T, originalResolver ContractResolver,
|
|||||||
case *htlcOutgoingContestResolver:
|
case *htlcOutgoingContestResolver:
|
||||||
diskRes := diskResolver.(*htlcOutgoingContestResolver)
|
diskRes := diskResolver.(*htlcOutgoingContestResolver)
|
||||||
assertTimeoutResEqual(
|
assertTimeoutResEqual(
|
||||||
&ogRes.htlcTimeoutResolver, &diskRes.htlcTimeoutResolver,
|
ogRes.htlcTimeoutResolver, diskRes.htlcTimeoutResolver,
|
||||||
)
|
)
|
||||||
|
|
||||||
case *htlcIncomingContestResolver:
|
case *htlcIncomingContestResolver:
|
||||||
diskRes := diskResolver.(*htlcIncomingContestResolver)
|
diskRes := diskResolver.(*htlcIncomingContestResolver)
|
||||||
assertSuccessResEqual(
|
assertSuccessResEqual(
|
||||||
&ogRes.htlcSuccessResolver, &diskRes.htlcSuccessResolver,
|
ogRes.htlcSuccessResolver, diskRes.htlcSuccessResolver,
|
||||||
)
|
)
|
||||||
|
|
||||||
if ogRes.htlcExpiry != diskRes.htlcExpiry {
|
if ogRes.htlcExpiry != diskRes.htlcExpiry {
|
||||||
@ -375,13 +375,13 @@ func TestContractInsertionRetrieval(t *testing.T) {
|
|||||||
contestTimeout := timeoutResolver
|
contestTimeout := timeoutResolver
|
||||||
contestTimeout.htlcResolution.ClaimOutpoint = randOutPoint()
|
contestTimeout.htlcResolution.ClaimOutpoint = randOutPoint()
|
||||||
resolvers = append(resolvers, &htlcOutgoingContestResolver{
|
resolvers = append(resolvers, &htlcOutgoingContestResolver{
|
||||||
htlcTimeoutResolver: contestTimeout,
|
htlcTimeoutResolver: &contestTimeout,
|
||||||
})
|
})
|
||||||
contestSuccess := successResolver
|
contestSuccess := successResolver
|
||||||
contestSuccess.htlcResolution.ClaimOutpoint = randOutPoint()
|
contestSuccess.htlcResolution.ClaimOutpoint = randOutPoint()
|
||||||
resolvers = append(resolvers, &htlcIncomingContestResolver{
|
resolvers = append(resolvers, &htlcIncomingContestResolver{
|
||||||
htlcExpiry: 100,
|
htlcExpiry: 100,
|
||||||
htlcSuccessResolver: contestSuccess,
|
htlcSuccessResolver: &contestSuccess,
|
||||||
})
|
})
|
||||||
|
|
||||||
// For quick lookup during the test, we'll create this map which allow
|
// For quick lookup during the test, we'll create this map which allow
|
||||||
@ -521,7 +521,7 @@ func TestContractSwapping(t *testing.T) {
|
|||||||
|
|
||||||
// We'll create two resolvers, a regular timeout resolver, and the
|
// We'll create two resolvers, a regular timeout resolver, and the
|
||||||
// contest resolver that eventually turns into the timeout resolver.
|
// contest resolver that eventually turns into the timeout resolver.
|
||||||
timeoutResolver := htlcTimeoutResolver{
|
timeoutResolver := &htlcTimeoutResolver{
|
||||||
htlcResolution: lnwallet.OutgoingHtlcResolution{
|
htlcResolution: lnwallet.OutgoingHtlcResolution{
|
||||||
Expiry: 99,
|
Expiry: 99,
|
||||||
SignedTimeoutTx: nil,
|
SignedTimeoutTx: nil,
|
||||||
@ -549,7 +549,7 @@ func TestContractSwapping(t *testing.T) {
|
|||||||
|
|
||||||
// With the resolver inserted, we'll now attempt to atomically swap it
|
// With the resolver inserted, we'll now attempt to atomically swap it
|
||||||
// for its underlying timeout resolver.
|
// for its underlying timeout resolver.
|
||||||
err = testLog.SwapContract(contestResolver, &timeoutResolver)
|
err = testLog.SwapContract(contestResolver, timeoutResolver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to swap contracts: %v", err)
|
t.Fatalf("unable to swap contracts: %v", err)
|
||||||
}
|
}
|
||||||
@ -566,7 +566,7 @@ func TestContractSwapping(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// That single contract should be the underlying timeout resolver.
|
// That single contract should be the underlying timeout resolver.
|
||||||
assertResolversEqual(t, &timeoutResolver, dbContracts[0])
|
assertResolversEqual(t, timeoutResolver, dbContracts[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestContractResolutionsStorage tests that we're able to properly store and
|
// TestContractResolutionsStorage tests that we're able to properly store and
|
||||||
|
@ -31,7 +31,7 @@ type htlcIncomingContestResolver struct {
|
|||||||
|
|
||||||
// htlcSuccessResolver is the inner resolver that may be utilized if we
|
// htlcSuccessResolver is the inner resolver that may be utilized if we
|
||||||
// learn of the preimage.
|
// learn of the preimage.
|
||||||
htlcSuccessResolver
|
*htlcSuccessResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
// newIncomingContestResolver instantiates a new incoming htlc contest resolver.
|
// newIncomingContestResolver instantiates a new incoming htlc contest resolver.
|
||||||
@ -45,7 +45,7 @@ func newIncomingContestResolver(
|
|||||||
|
|
||||||
return &htlcIncomingContestResolver{
|
return &htlcIncomingContestResolver{
|
||||||
htlcExpiry: htlc.RefundTimeout,
|
htlcExpiry: htlc.RefundTimeout,
|
||||||
htlcSuccessResolver: *success,
|
htlcSuccessResolver: success,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &h.htlcSuccessResolver, nil
|
return h.htlcSuccessResolver, nil
|
||||||
|
|
||||||
// If the htlc was failed, mark the htlc as
|
// If the htlc was failed, mark the htlc as
|
||||||
// resolved.
|
// resolved.
|
||||||
@ -293,7 +293,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &h.htlcSuccessResolver, nil
|
return h.htlcSuccessResolver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
witnessUpdates = preimageSubscription.WitnessUpdates
|
witnessUpdates = preimageSubscription.WitnessUpdates
|
||||||
@ -315,7 +315,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
// We've learned of the preimage and this information
|
// We've learned of the preimage and this information
|
||||||
// has been added to our inner resolver. We return it so
|
// has been added to our inner resolver. We return it so
|
||||||
// it can continue contract resolution.
|
// it can continue contract resolution.
|
||||||
return &h.htlcSuccessResolver, nil
|
return h.htlcSuccessResolver, nil
|
||||||
|
|
||||||
case hodlItem := <-hodlChan:
|
case hodlItem := <-hodlChan:
|
||||||
htlcResolution := hodlItem.(invoices.HtlcResolution)
|
htlcResolution := hodlItem.(invoices.HtlcResolution)
|
||||||
@ -420,7 +420,7 @@ func newIncomingContestResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
h.htlcSuccessResolver = *successResolver
|
h.htlcSuccessResolver = successResolver
|
||||||
|
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ func newIncomingResolverTestContext(t *testing.T, isExit bool) *incomingResolver
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
resolver := &htlcIncomingContestResolver{
|
resolver := &htlcIncomingContestResolver{
|
||||||
htlcSuccessResolver: htlcSuccessResolver{
|
htlcSuccessResolver: &htlcSuccessResolver{
|
||||||
contractResolverKit: *newContractResolverKit(cfg),
|
contractResolverKit: *newContractResolverKit(cfg),
|
||||||
htlcResolution: lnwallet.IncomingHtlcResolution{},
|
htlcResolution: lnwallet.IncomingHtlcResolution{},
|
||||||
htlc: channeldb.HTLC{
|
htlc: channeldb.HTLC{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
type htlcOutgoingContestResolver struct {
|
type htlcOutgoingContestResolver struct {
|
||||||
// htlcTimeoutResolver is the inner solver that this resolver may turn
|
// htlcTimeoutResolver is the inner solver that this resolver may turn
|
||||||
// into. This only happens if the HTLC expires on-chain.
|
// into. This only happens if the HTLC expires on-chain.
|
||||||
htlcTimeoutResolver
|
*htlcTimeoutResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
// newOutgoingContestResolver instantiates a new outgoing contested htlc
|
// newOutgoingContestResolver instantiates a new outgoing contested htlc
|
||||||
@ -31,7 +31,7 @@ func newOutgoingContestResolver(res lnwallet.OutgoingHtlcResolution,
|
|||||||
)
|
)
|
||||||
|
|
||||||
return &htlcOutgoingContestResolver{
|
return &htlcOutgoingContestResolver{
|
||||||
htlcTimeoutResolver: *timeout,
|
htlcTimeoutResolver: timeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
"into timeout resolver", h,
|
"into timeout resolver", h,
|
||||||
h.htlcResolution.ClaimOutpoint,
|
h.htlcResolution.ClaimOutpoint,
|
||||||
newHeight, h.htlcResolution.Expiry)
|
newHeight, h.htlcResolution.Expiry)
|
||||||
return &h.htlcTimeoutResolver, nil
|
return h.htlcTimeoutResolver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// The output has been spent! This means the preimage has been
|
// The output has been spent! This means the preimage has been
|
||||||
@ -209,7 +209,7 @@ func newOutgoingContestResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
h.htlcTimeoutResolver = *timeoutResolver
|
h.htlcTimeoutResolver = timeoutResolver
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ func newOutgoingResolverTestContext(t *testing.T) *outgoingResolverTestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolver := &htlcOutgoingContestResolver{
|
resolver := &htlcOutgoingContestResolver{
|
||||||
htlcTimeoutResolver: htlcTimeoutResolver{
|
htlcTimeoutResolver: &htlcTimeoutResolver{
|
||||||
contractResolverKit: *newContractResolverKit(cfg),
|
contractResolverKit: *newContractResolverKit(cfg),
|
||||||
htlcResolution: outgoingRes,
|
htlcResolution: outgoingRes,
|
||||||
htlc: channeldb.HTLC{
|
htlc: channeldb.HTLC{
|
||||||
|
Loading…
Reference in New Issue
Block a user