From 1758ad829f37272904c1fcffb5c86b3f59b5a4e1 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 21 Aug 2018 12:21:16 +0200 Subject: [PATCH] contractcourt/[chain|channel]_arbitrator: define IsPendingClose --- contractcourt/chain_arbitrator.go | 4 ++++ contractcourt/channel_arbitrator.go | 12 ++++++++++++ contractcourt/channel_arbitrator_test.go | 1 + 3 files changed, 17 insertions(+) diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index 5525c185..b8491b06 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -244,6 +244,7 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel, }, MarkCommitmentBroadcasted: channel.MarkCommitmentBroadcasted, MarkChannelClosed: channel.CloseChannel, + IsPendingClose: false, ChainArbitratorConfig: c.cfg, ChainEvents: chanEvents, } @@ -399,6 +400,9 @@ func (c *ChainArbitrator) Start() error { BlockEpochs: blockEpoch, ChainArbitratorConfig: c.cfg, ChainEvents: &ChainEventSubscription{}, + IsPendingClose: true, + ClosingHeight: closeChanInfo.CloseHeight, + CloseType: closeChanInfo.CloseType, } chanLog, err := newBoltArbitratorLog( c.chanSource.DB, arbCfg, c.cfg.ChainHash, chanPoint, diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index 9cd2fee2..f6ef30fb 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -101,6 +101,18 @@ type ChannelArbitratorConfig struct { // again. MarkChannelClosed func(*channeldb.ChannelCloseSummary) error + // IsPendingClose is a boolean indicating whether the channel is marked + // as pending close in the database. + IsPendingClose bool + + // ClosingHeight is the height at which the channel was closed. Note + // that this value is only valid if IsPendingClose is true. + ClosingHeight uint32 + + // CloseType is the type of the close event in case IsPendingClose is + // true. Otherwise this value is unset. + CloseType channeldb.ClosureType + // MarkChannelResolved is a function closure that serves to mark a // channel as "fully resolved". A channel itself can be considered // fully resolved once all active contracts have individually been diff --git a/contractcourt/channel_arbitrator_test.go b/contractcourt/channel_arbitrator_test.go index 6f4b7f2e..aeedf47c 100644 --- a/contractcourt/channel_arbitrator_test.go +++ b/contractcourt/channel_arbitrator_test.go @@ -149,6 +149,7 @@ func createTestChannelArbitrator(log ArbitratorLog) (*ChannelArbitrator, MarkChannelClosed: func(*channeldb.ChannelCloseSummary) error { return nil }, + IsPendingClose: false, ChainArbitratorConfig: chainArbCfg, ChainEvents: chanEvents, }