contractcourt: add PutResolverReport function to chanArb config

This commit is contained in:
carla 2020-07-07 19:49:50 +02:00
parent 578af99618
commit 8c8f857f60
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
8 changed files with 62 additions and 4 deletions

@ -133,7 +133,12 @@ func newTestBoltArbLog(chainhash chainhash.Hash,
return nil, nil, err
}
testArbCfg := ChannelArbitratorConfig{}
testArbCfg := ChannelArbitratorConfig{
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
}
testLog, err := newBoltArbitratorLog(testDB, testArbCfg, chainhash, op)
if err != nil {
return nil, nil, err

@ -12,6 +12,7 @@ import (
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet"
@ -347,6 +348,14 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel,
IsPendingClose: false,
ChainArbitratorConfig: c.cfg,
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
@ -552,6 +561,13 @@ func (c *ChainArbitrator) Start() error {
IsPendingClose: true,
ClosingHeight: closeChanInfo.CloseHeight,
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(
c.chanSource.Backend, arbCfg, c.cfg.ChainHash, chanPoint,

@ -13,6 +13,7 @@ import (
"github.com/davecgh/go-spew/spew"
"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/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
@ -143,6 +144,12 @@ type ChannelArbitratorConfig struct {
// TODO(roasbeef): need RPC's to combine for pendingchannels RPC
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
}

@ -380,6 +380,11 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog,
IsPendingClose: false,
ChainArbitratorConfig: chainArbCfg,
ChainEvents: chanEvents,
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
}
// Apply all custom options to the config struct.

@ -7,6 +7,8 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"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/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
@ -39,6 +41,11 @@ func newCommitSweepResolverTestContext(t *testing.T,
Notifier: notifier,
Sweeper: sweeper,
},
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
}
cfg := ResolverConfig{

@ -6,13 +6,13 @@ import (
"io/ioutil"
"testing"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
)
const (
@ -251,6 +251,11 @@ func newIncomingResolverTestContext(t *testing.T) *incomingResolverTestContext {
Registry: registry,
OnionProcessor: onionProcessor,
},
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
}
cfg := ResolverConfig{

@ -7,6 +7,7 @@ import (
"github.com/btcsuite/btcd/wire"
"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/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
@ -117,6 +118,11 @@ func newOutgoingResolverTestContext(t *testing.T) *outgoingResolverTestContext {
},
OnionProcessor: onionProcessor,
},
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
}
outgoingRes := lnwallet.OutgoingHtlcResolution{

@ -11,6 +11,8 @@ import (
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"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/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
@ -248,6 +250,11 @@ func TestHtlcTimeoutResolver(t *testing.T) {
return nil
},
},
PutResolverReport: func(_ kvdb.RwTx,
_ *channeldb.ResolverReport) error {
return nil
},
}
cfg := ResolverConfig{