@@ -53,12 +53,12 @@ var (
5353 // for the first and one for the second level).
5454 taprootRetributionBucket = []byte ("tap-retribution" )
5555
56- // errBrarShuttingDown is an error returned if the breacharbiter has
56+ // errBrarShuttingDown is an error returned if the BreachArbitrator has
5757 // been signalled to exit.
58- errBrarShuttingDown = errors .New ("breacharbiter shutting down" )
58+ errBrarShuttingDown = errors .New ("BreachArbitrator shutting down" )
5959)
6060
61- // ContractBreachEvent is an event the BreachArbiter will receive in case a
61+ // ContractBreachEvent is an event the BreachArbitrator will receive in case a
6262// contract breach is observed on-chain. It contains the necessary information
6363// to handle the breach, and a ProcessACK closure we will use to ACK the event
6464// when we have safely stored all the necessary information.
@@ -71,7 +71,7 @@ type ContractBreachEvent struct {
7171 // store. In case storing the information to the store fails, a non-nil
7272 // error should be used. When this closure returns, it means that the
7373 // contract court has marked the channel pending close in the DB, and
74- // it is safe for the BreachArbiter to carry on its duty.
74+ // it is safe for the BreachArbitrator to carry on its duty.
7575 ProcessACK func (error )
7676
7777 // BreachRetribution is the information needed to act on this contract
@@ -94,11 +94,12 @@ const (
9494)
9595
9696// RetributionStorer provides an interface for managing a persistent map from
97- // wire.OutPoint -> retributionInfo. Upon learning of a breach, a BreachArbiter
98- // should record the retributionInfo for the breached channel, which serves a
99- // checkpoint in the event that retribution needs to be resumed after failure.
100- // A RetributionStore provides an interface for managing the persisted set, as
101- // well as mapping user defined functions over the entire on-disk contents.
97+ // wire.OutPoint -> retributionInfo. Upon learning of a breach, a
98+ // BreachArbitrator should record the retributionInfo for the breached channel,
99+ // which serves a checkpoint in the event that retribution needs to be resumed
100+ // after failure. A RetributionStore provides an interface for managing the
101+ // persisted set, as well as mapping user defined functions over the entire
102+ // on-disk contents.
102103//
103104// Calls to RetributionStore may occur concurrently. A concrete instance of
104105// RetributionStore should use appropriate synchronization primitives, or
@@ -125,7 +126,8 @@ type RetributionStorer interface {
125126}
126127
127128// BreachConfig bundles the required subsystems used by the breach arbiter. An
128- // instance of BreachConfig is passed to newBreachArbiter during instantiation.
129+ // instance of BreachConfig is passed to NewBreachArbitrator during
130+ // instantiation.
129131type BreachConfig struct {
130132 // CloseLink allows the breach arbiter to shutdown any channel links for
131133 // which it detects a breach, ensuring now further activity will
@@ -154,9 +156,9 @@ type BreachConfig struct {
154156 // transaction to the network.
155157 PublishTransaction func (* wire.MsgTx , string ) error
156158
157- // ContractBreaches is a channel where the BreachArbiter will receive
159+ // ContractBreaches is a channel where the BreachArbitrator will receive
158160 // notifications in the event of a contract breach being observed. A
159- // ContractBreachEvent must be ACKed by the BreachArbiter , such that
161+ // ContractBreachEvent must be ACKed by the BreachArbitrator , such that
160162 // the sending subsystem knows that the event is properly handed off.
161163 ContractBreaches <- chan * ContractBreachEvent
162164
@@ -171,15 +173,15 @@ type BreachConfig struct {
171173 Store RetributionStorer
172174}
173175
174- // BreachArbiter is a special subsystem which is responsible for watching and
176+ // BreachArbitrator is a special subsystem which is responsible for watching and
175177// acting on the detection of any attempted uncooperative channel breaches by
176178// channel counterparties. This file essentially acts as deterrence code for
177179// those attempting to launch attacks against the daemon. In practice it's
178180// expected that the logic in this file never gets executed, but it is
179181// important to have it in place just in case we encounter cheating channel
180182// counterparties.
181183// TODO(roasbeef): closures in config for subsystem pointers to decouple?
182- type BreachArbiter struct {
184+ type BreachArbitrator struct {
183185 started sync.Once
184186 stopped sync.Once
185187
@@ -192,19 +194,19 @@ type BreachArbiter struct {
192194 sync.Mutex
193195}
194196
195- // NewBreachArbiter creates a new instance of a BreachArbiter initialized with
196- // its dependent objects.
197- func NewBreachArbiter (cfg * BreachConfig ) * BreachArbiter {
198- return & BreachArbiter {
197+ // NewBreachArbitrator creates a new instance of a BreachArbitrator initialized
198+ // with its dependent objects.
199+ func NewBreachArbitrator (cfg * BreachConfig ) * BreachArbitrator {
200+ return & BreachArbitrator {
199201 cfg : cfg ,
200202 subscriptions : make (map [wire.OutPoint ]chan struct {}),
201203 quit : make (chan struct {}),
202204 }
203205}
204206
205- // Start is an idempotent method that officially starts the BreachArbiter along
206- // with all other goroutines it needs to perform its functions.
207- func (b * BreachArbiter ) Start () error {
207+ // Start is an idempotent method that officially starts the BreachArbitrator
208+ // along with all other goroutines it needs to perform its functions.
209+ func (b * BreachArbitrator ) Start () error {
208210 var err error
209211 b .started .Do (func () {
210212 brarLog .Info ("Breach arbiter starting" )
@@ -213,7 +215,7 @@ func (b *BreachArbiter) Start() error {
213215 return err
214216}
215217
216- func (b * BreachArbiter ) start () error {
218+ func (b * BreachArbitrator ) start () error {
217219 // Load all retributions currently persisted in the retribution store.
218220 var breachRetInfos map [wire.OutPoint ]retributionInfo
219221 if err := b .cfg .Store .ForAll (func (ret * retributionInfo ) error {
@@ -305,10 +307,10 @@ func (b *BreachArbiter) start() error {
305307 return nil
306308}
307309
308- // Stop is an idempotent method that signals the BreachArbiter to execute a
310+ // Stop is an idempotent method that signals the BreachArbitrator to execute a
309311// graceful shutdown. This function will block until all goroutines spawned by
310- // the BreachArbiter have gracefully exited.
311- func (b * BreachArbiter ) Stop () error {
312+ // the BreachArbitrator have gracefully exited.
313+ func (b * BreachArbitrator ) Stop () error {
312314 b .stopped .Do (func () {
313315 brarLog .Infof ("Breach arbiter shutting down..." )
314316 defer brarLog .Debug ("Breach arbiter shutdown complete" )
@@ -321,13 +323,13 @@ func (b *BreachArbiter) Stop() error {
321323
322324// IsBreached queries the breach arbiter's retribution store to see if it is
323325// aware of any channel breaches for a particular channel point.
324- func (b * BreachArbiter ) IsBreached (chanPoint * wire.OutPoint ) (bool , error ) {
326+ func (b * BreachArbitrator ) IsBreached (chanPoint * wire.OutPoint ) (bool , error ) {
325327 return b .cfg .Store .IsBreached (chanPoint )
326328}
327329
328330// SubscribeBreachComplete is used by outside subsystems to be notified of a
329331// successful breach resolution.
330- func (b * BreachArbiter ) SubscribeBreachComplete (chanPoint * wire.OutPoint ,
332+ func (b * BreachArbitrator ) SubscribeBreachComplete (chanPoint * wire.OutPoint ,
331333 c chan struct {}) (bool , error ) {
332334
333335 breached , err := b .cfg .Store .IsBreached (chanPoint )
@@ -353,9 +355,9 @@ func (b *BreachArbiter) SubscribeBreachComplete(chanPoint *wire.OutPoint,
353355 return false , nil
354356}
355357
356- // notifyBreachComplete is used by the BreachArbiter to notify outside
358+ // notifyBreachComplete is used by the BreachArbitrator to notify outside
357359// subsystems that the breach resolution process is complete.
358- func (b * BreachArbiter ) notifyBreachComplete (chanPoint * wire.OutPoint ) {
360+ func (b * BreachArbitrator ) notifyBreachComplete (chanPoint * wire.OutPoint ) {
359361 b .Lock ()
360362 defer b .Unlock ()
361363 if c , ok := b .subscriptions [* chanPoint ]; ok {
@@ -366,15 +368,15 @@ func (b *BreachArbiter) notifyBreachComplete(chanPoint *wire.OutPoint) {
366368 delete (b .subscriptions , * chanPoint )
367369}
368370
369- // contractObserver is the primary goroutine for the BreachArbiter . This
371+ // contractObserver is the primary goroutine for the BreachArbitrator . This
370372// goroutine is responsible for handling breach events coming from the
371373// contractcourt on the ContractBreaches channel. If a channel breach is
372374// detected, then the contractObserver will execute the retribution logic
373375// required to sweep ALL outputs from a contested channel into the daemon's
374376// wallet.
375377//
376378// NOTE: This MUST be run as a goroutine.
377- func (b * BreachArbiter ) contractObserver () {
379+ func (b * BreachArbitrator ) contractObserver () {
378380 defer b .wg .Done ()
379381
380382 brarLog .Infof ("Starting contract observer, watching for breaches." )
@@ -406,7 +408,7 @@ type spend struct {
406408// returns the spend details for those outputs. The spendNtfns map is a cache
407409// used to store registered spend subscriptions, in case we must call this
408410// method multiple times.
409- func (b * BreachArbiter ) waitForSpendEvent (breachInfo * retributionInfo ,
411+ func (b * BreachArbitrator ) waitForSpendEvent (breachInfo * retributionInfo ,
410412 spendNtfns map [wire.OutPoint ]* chainntnfs.SpendEvent ) ([]spend , error ) {
411413
412414 inputs := breachInfo .breachedOutputs
@@ -684,8 +686,10 @@ func updateBreachInfo(breachInfo *retributionInfo, spends []spend) (
684686// the lingering funds within the channel into the daemon's wallet.
685687//
686688// NOTE: This MUST be run as a goroutine.
687- func (b * BreachArbiter ) exactRetribution (confChan * chainntnfs.ConfirmationEvent ,
688- breachInfo * retributionInfo ) {
689+ //
690+ //nolint:funlen
691+ func (b * BreachArbitrator ) exactRetribution (
692+ confChan * chainntnfs.ConfirmationEvent , breachInfo * retributionInfo ) {
689693
690694 defer b .wg .Done ()
691695
@@ -916,7 +920,7 @@ Loop:
916920
917921// cleanupBreach marks the given channel point as fully resolved and removes the
918922// retribution for that the channel from the retribution store.
919- func (b * BreachArbiter ) cleanupBreach (chanPoint * wire.OutPoint ) error {
923+ func (b * BreachArbitrator ) cleanupBreach (chanPoint * wire.OutPoint ) error {
920924 // With the channel closed, mark it in the database as such.
921925 err := b .cfg .DB .MarkChanFullyClosed (chanPoint )
922926 if err != nil {
@@ -943,15 +947,17 @@ func (b *BreachArbiter) cleanupBreach(chanPoint *wire.OutPoint) error {
943947}
944948
945949// handleBreachHandoff handles a new breach event, by writing it to disk, then
946- // notifies the BreachArbiter contract observer goroutine that a channel's
950+ // notifies the BreachArbitrator contract observer goroutine that a channel's
947951// contract has been breached by the prior counterparty. Once notified the
948- // BreachArbiter will attempt to sweep ALL funds within the channel using the
952+ // BreachArbitrator will attempt to sweep ALL funds within the channel using the
949953// information provided within the BreachRetribution generated due to the
950954// breach of channel contract. The funds will be swept only after the breaching
951955// transaction receives a necessary number of confirmations.
952956//
953957// NOTE: This MUST be run as a goroutine.
954- func (b * BreachArbiter ) handleBreachHandoff (breachEvent * ContractBreachEvent ) {
958+ func (b * BreachArbitrator ) handleBreachHandoff (
959+ breachEvent * ContractBreachEvent ) {
960+
955961 defer b .wg .Done ()
956962
957963 chanPoint := breachEvent .ChanPoint
@@ -1367,7 +1373,7 @@ type justiceTxVariants struct {
13671373// the funds within the channel which we are now entitled to due to a breach of
13681374// the channel's contract by the counterparty. This function returns a *fully*
13691375// signed transaction with the witness for each input fully in place.
1370- func (b * BreachArbiter ) createJusticeTx (
1376+ func (b * BreachArbitrator ) createJusticeTx (
13711377 breachedOutputs []breachedOutput ) (* justiceTxVariants , error ) {
13721378
13731379 var (
@@ -1442,7 +1448,7 @@ func (b *BreachArbiter) createJusticeTx(
14421448}
14431449
14441450// createSweepTx creates a tx that sweeps the passed inputs back to our wallet.
1445- func (b * BreachArbiter ) createSweepTx (inputs ... input.Input ) (* wire.MsgTx ,
1451+ func (b * BreachArbitrator ) createSweepTx (inputs ... input.Input ) (* wire.MsgTx ,
14461452 error ) {
14471453
14481454 if len (inputs ) == 0 {
@@ -1498,7 +1504,7 @@ func (b *BreachArbiter) createSweepTx(inputs ...input.Input) (*wire.MsgTx,
14981504
14991505// sweepSpendableOutputsTxn creates a signed transaction from a sequence of
15001506// spendable outputs by sweeping the funds into a single p2wkh output.
1501- func (b * BreachArbiter ) sweepSpendableOutputsTxn (txWeight int64 ,
1507+ func (b * BreachArbitrator ) sweepSpendableOutputsTxn (txWeight int64 ,
15021508 inputs ... input.Input ) (* wire.MsgTx , error ) {
15031509
15041510 // First, we obtain a new public key script from the wallet which we'll
0 commit comments