contractcourt: add PutResolverReport function to chanArb config

This commit is contained in:
carla committed 2020-07-07 19:49:50 +02:00
1 parent 578af99618
commit 8c8f857f60
8 files changed
+62 -4

No files matched your search

+6 -1
View File
@@ -133,7 +133,12 @@ func newTestBoltArbLog(chainhash chainhash.Hash,
return nil, nil, err return nil, nil, err
} }
testArbCfg := ChannelArbitratorConfig{} testArbCfg := ChannelArbitratorConfig{
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
}
testLog, err := newBoltArbitratorLog(testDB, testArbCfg, chainhash, op) testLog, err := newBoltArbitratorLog(testDB, testArbCfg, chainhash, op)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
+16
View File
@@ -12,6 +12,7 @@ import (
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
@@ -347,6 +348,14 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel,
IsPendingClose: false, IsPendingClose: false,
ChainArbitratorConfig: c.cfg, ChainArbitratorConfig: c.cfg,
ChainEvents: chanEvents, ChainEvents: chanEvents,
PutResolverReport: func(tx kvdb.RwTx,
report *channeldb.ResolverReport) error {
return c.chanSource.PutResolverReport(
tx, c.cfg.ChainHash, &channel.FundingOutpoint,
report,
)
},
} }
// The final component needed is an arbitrator log that the arbitrator // The final component needed is an arbitrator log that the arbitrator
@@ -552,6 +561,13 @@ func (c *ChainArbitrator) Start() error {
IsPendingClose: true, IsPendingClose: true,
ClosingHeight: closeChanInfo.CloseHeight, ClosingHeight: closeChanInfo.CloseHeight,
CloseType: closeChanInfo.CloseType, CloseType: closeChanInfo.CloseType,
PutResolverReport: func(tx kvdb.RwTx,
report *channeldb.ResolverReport) error {
return c.chanSource.PutResolverReport(
tx, c.cfg.ChainHash, &chanPoint, report,
)
},
} }
chanLog, err := newBoltArbitratorLog( chanLog, err := newBoltArbitratorLog(
c.chanSource.Backend, arbCfg, c.cfg.ChainHash, chanPoint, c.chanSource.Backend, arbCfg, c.cfg.ChainHash, chanPoint,
+7
View File
@@ -13,6 +13,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
@@ -143,6 +144,12 @@ type ChannelArbitratorConfig struct {
// TODO(roasbeef): need RPC's to combine for pendingchannels RPC // TODO(roasbeef): need RPC's to combine for pendingchannels RPC
MarkChannelResolved func() error MarkChannelResolved func() error
// PutResolverReport records a resolver report for the channel. If the
// transaction provided is nil, the function should write the report
// in a new transaction.
PutResolverReport func(tx kvdb.RwTx,
report *channeldb.ResolverReport) error
ChainArbitratorConfig ChainArbitratorConfig
} }
+5
View File
@@ -380,6 +380,11 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog,
IsPendingClose: false, IsPendingClose: false,
ChainArbitratorConfig: chainArbCfg, ChainArbitratorConfig: chainArbCfg,
ChainEvents: chanEvents, ChainEvents: chanEvents,
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
} }
// Apply all custom options to the config struct. // Apply all custom options to the config struct.
@@ -7,6 +7,8 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
@@ -39,6 +41,11 @@ func newCommitSweepResolverTestContext(t *testing.T,
Notifier: notifier, Notifier: notifier,
Sweeper: sweeper, Sweeper: sweeper,
}, },
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
} }
cfg := ResolverConfig{ cfg := ResolverConfig{
+8 -3
View File
@@ -6,13 +6,13 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
) )
const ( const (
@@ -251,6 +251,11 @@ func newIncomingResolverTestContext(t *testing.T) *incomingResolverTestContext {
Registry: registry, Registry: registry,
OnionProcessor: onionProcessor, OnionProcessor: onionProcessor,
}, },
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
} }
cfg := ResolverConfig{ cfg := ResolverConfig{
@@ -7,6 +7,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
@@ -117,6 +118,11 @@ func newOutgoingResolverTestContext(t *testing.T) *outgoingResolverTestContext {
}, },
OnionProcessor: onionProcessor, OnionProcessor: onionProcessor,
}, },
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
} }
outgoingRes := lnwallet.OutgoingHtlcResolution{ outgoingRes := lnwallet.OutgoingHtlcResolution{
@@ -11,6 +11,8 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
@@ -248,6 +250,11 @@ func TestHtlcTimeoutResolver(t *testing.T) {
return nil return nil
}, },
}, },
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
} }
cfg := ResolverConfig{ cfg := ResolverConfig{