trivial: clean up typos and comments

pull/622/head
Slyghtning 9 months ago
parent 24987ddf10
commit 20316042d9
No known key found for this signature in database
GPG Key ID: F82D456EA023C9BF

@ -272,9 +272,7 @@ func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) {
// restored from persistent storage and resumed. Subsequent updates will be
// sent through the passed in statusChan. The function can be terminated by
// cancelling the context.
func (s *Client) Run(ctx context.Context,
statusChan chan<- SwapInfo) error {
func (s *Client) Run(ctx context.Context, statusChan chan<- SwapInfo) error {
if !atomic.CompareAndSwapUint32(&s.started, 0, 1) {
return errors.New("swap client can only be started once")
}
@ -284,7 +282,7 @@ func (s *Client) Run(ctx context.Context,
s.lndServices.NodeAlias, s.lndServices.NodePubkey,
lndclient.VersionString(s.lndServices.Version))
// Setup main context used for cancelation.
// Setup main context used for cancellation.
mainCtx, mainCancel := context.WithCancel(ctx)
defer mainCancel()
@ -307,7 +305,7 @@ func (s *Client) Run(ctx context.Context,
s.resumeSwaps(mainCtx, pendingLoopOutSwaps, pendingLoopInSwaps)
// Signal that new requests can be accepted. Otherwise the new
// Signal that new requests can be accepted. Otherwise, the new
// swap could already have been added to the store and read in
// this goroutine as being a swap that needs to be resumed.
// Resulting in two goroutines executing the same swap.

@ -71,34 +71,35 @@ func (s *executor) run(mainCtx context.Context,
for {
blockEpochChan, blockErrorChan, err =
s.lnd.ChainNotifier.RegisterBlockEpochNtfn(mainCtx)
if err != nil {
if strings.Contains(err.Error(),
"in the process of starting") {
log.Warnf("LND chain notifier server not " +
"ready yet, retrying with delay")
if err == nil {
break
}
// Give chain notifier some time to start and
// try to re-attempt block epoch subscription.
select {
case <-time.After(500 * time.Millisecond):
continue
if strings.Contains(err.Error(),
"in the process of starting") {
case <-mainCtx.Done():
return err
}
}
log.Warnf("LND chain notifier server not ready yet, " +
"retrying with delay")
// Give chain notifier some time to start and try to
// re-attempt block epoch subscription.
select {
case <-time.After(500 * time.Millisecond):
continue
return err
case <-mainCtx.Done():
return err
}
}
break
return err
}
// Before starting, make sure we have an up to date block height.
// Otherwise we might reveal a preimage for a swap that is already
// Before starting, make sure we have an up-to-date block height.
// Otherwise, we might reveal a preimage for a swap that is already
// expired.
log.Infof("Wait for first block ntfn")
log.Infof("Wait for first block notification")
var height int32
setHeight := func(h int32) {
@ -118,7 +119,7 @@ func (s *executor) run(mainCtx context.Context,
// Start main event loop.
log.Infof("Starting event loop at height %v", height)
// Signal that executor being ready with an up to date block height.
// Signal that executor being ready with an up-to-date block height.
close(s.ready)
// Use a map to administer the individual notification queues for the

@ -95,7 +95,7 @@ func New(config *Config, lisCfg *ListenerCfg) *Daemon {
// We send exactly one error on this channel if something goes
// wrong at runtime. Or a nil value if the shutdown was
// successful. But in case nobody's listening, we don't want to
// block on it so we buffer it.
// block on it, so we buffer it.
ErrChan: make(chan error, 1),
quit: make(chan struct{}),
@ -135,9 +135,9 @@ func (d *Daemon) Start() error {
if errors.Is(err, bbolt.ErrTimeout) {
// We're trying to be started as a standalone Loop daemon, most
// likely LiT is already running and blocking the DB
return fmt.Errorf("%v: make sure no other loop daemon "+
"process (standalone or embedded in "+
"lightning-terminal) is running", err)
return fmt.Errorf("%v: make sure no other loop daemon process "+
"(standalone or embedded in lightning-terminal) is"+
"running", err)
}
if err != nil {
return err
@ -166,9 +166,9 @@ func (d *Daemon) Start() error {
func (d *Daemon) StartAsSubserver(lndGrpc *lndclient.GrpcLndServices,
withMacaroonService bool) error {
// There should be no reason to start the daemon twice. Therefore return
// an error if that's tried. This is mostly to guard against Start and
// StartAsSubserver both being called.
// There should be no reason to start the daemon twice. Therefore,
// return an error if that's tried. This is mostly to guard against
// Start and StartAsSubserver both being called.
if atomic.AddInt32(&d.started, 1) != 1 {
return errOnlyStartOnce
}
@ -179,8 +179,8 @@ func (d *Daemon) StartAsSubserver(lndGrpc *lndclient.GrpcLndServices,
// With lnd already pre-connected, initialize everything else, such as
// the swap server client, the RPC server instance and our main swap
// handlers. If this fails, then nothing has been started yet and we can
// just return the error.
// handlers. If this fails, then nothing has been started yet, and we
// can just return the error.
err := d.initialize(withMacaroonService)
if errors.Is(err, bbolt.ErrTimeout) {
// We're trying to be started inside LiT so there most likely is
@ -370,8 +370,8 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
}
}
// Both the client RPC server and and the swap server client should
// stop on main context cancel. So we create it early and pass it down.
// Both the client RPC server and the swap server client should stop
// on main context cancel. So we create it early and pass it down.
d.mainCtx, d.mainCtxCancel = context.WithCancel(context.Background())
log.Infof("Swap server address: %v", d.cfg.Server.Host)

@ -561,7 +561,7 @@ func (s *swapClientServer) LoopOutQuote(ctx context.Context,
}, nil
}
// GetTerms returns the terms that the server enforces for swaps.
// GetLoopInTerms returns the terms that the server enforces for swaps.
func (s *swapClientServer) GetLoopInTerms(ctx context.Context,
req *clientrpc.TermsRequest) (*clientrpc.InTermsResponse, error) {
@ -579,7 +579,7 @@ func (s *swapClientServer) GetLoopInTerms(ctx context.Context,
}, nil
}
// GetQuote returns a quote for a swap with the provided parameters.
// GetLoopInQuote returns a quote for a swap with the provided parameters.
func (s *swapClientServer) GetLoopInQuote(ctx context.Context,
req *clientrpc.QuoteRequest) (*clientrpc.InQuoteResponse, error) {

@ -817,8 +817,9 @@ func (s *loopInSwap) waitForSwapComplete(ctx context.Context,
return fmt.Errorf("subscribe to swap invoice: %v", err)
}
// checkTimeout publishes the timeout tx if the contract has expired.
checkTimeout := func() (btcutil.Amount, error) {
// publishTxOnTimeout publishes the timeout tx if the contract has
// expired.
publishTxOnTimeout := func() (btcutil.Amount, error) {
if s.height >= s.LoopInContract.CltvExpiry {
return s.publishTimeoutTx(ctx, htlcOutpoint, htlcValue)
}
@ -829,7 +830,7 @@ func (s *loopInSwap) waitForSwapComplete(ctx context.Context,
// Check timeout at current height. After a restart we may want to
// publish the tx immediately.
var sweepFee btcutil.Amount
sweepFee, err = checkTimeout()
sweepFee, err = publishTxOnTimeout()
if err != nil {
return err
}
@ -848,7 +849,7 @@ func (s *loopInSwap) waitForSwapComplete(ctx context.Context,
case notification := <-s.blockEpochChan:
s.height = notification.(int32)
sweepFee, err = checkTimeout()
sweepFee, err = publishTxOnTimeout()
if err != nil {
return err
}
@ -971,7 +972,7 @@ func (s *loopInSwap) processHtlcSpend(ctx context.Context,
sweepFee btcutil.Amount) error {
// Determine the htlc input of the spending tx and inspect the witness
// to findout whether a success or a timeout tx spend the htlc.
// to find out whether a success or a timeout tx spent the htlc.
htlcInput := spend.SpendingTx.TxIn[spend.SpenderInputIndex]
if s.htlc.IsSuccessWitness(htlcInput.Witness) {

Loading…
Cancel
Save