lnwallet: clarify usage of cancel and response channels

This commit is contained in:
Oliver Gugger 2024-09-11 15:28:46 +02:00
parent 953fb073d4
commit f52a163334
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
2 changed files with 17 additions and 15 deletions

View File

@ -151,18 +151,19 @@ type AuxSigJob struct {
BaseAuxJob BaseAuxJob
// Resp is a channel that will be used to send the result of the sign // Resp is a channel that will be used to send the result of the sign
// job. // job. This channel MUST be buffered.
Resp chan AuxSigJobResp Resp chan AuxSigJobResp
// Cancel is a channel that should be closed if the caller wishes to // Cancel is a channel that is closed by the caller if they wish to
// abandon all pending sign jobs part of a single batch. // abandon all pending sign jobs part of a single batch. This should
Cancel chan struct{} // never be closed by the validator.
Cancel <-chan struct{}
} }
// NewAuxSigJob creates a new AuxSigJob. // NewAuxSigJob creates a new AuxSigJob.
func NewAuxSigJob(sigJob SignJob, keyRing CommitmentKeyRing, incoming bool, func NewAuxSigJob(sigJob SignJob, keyRing CommitmentKeyRing, incoming bool,
htlc AuxHtlcDescriptor, commitBlob fn.Option[tlv.Blob], htlc AuxHtlcDescriptor, commitBlob fn.Option[tlv.Blob],
htlcLeaf input.AuxTapLeaf, cancelChan chan struct{}) AuxSigJob { htlcLeaf input.AuxTapLeaf, cancelChan <-chan struct{}) AuxSigJob {
return AuxSigJob{ return AuxSigJob{
SignDesc: sigJob.SignDesc, SignDesc: sigJob.SignDesc,

View File

@ -45,17 +45,17 @@ type VerifyJob struct {
// party's update log. // party's update log.
HtlcIndex uint64 HtlcIndex uint64
// Cancel is a channel that should be closed if the caller wishes to // Cancel is a channel that is closed by the caller if they wish to
// cancel all pending verification jobs part of a single batch. This // cancel all pending verification jobs part of a single batch. This
// channel is to be closed in the case that a single signature in a // channel is closed in the case that a single signature in a batch has
// batch has been returned as invalid, as there is no need to verify // been returned as invalid, as there is no need to verify the remainder
// the remainder of the signatures. // of the signatures.
Cancel chan struct{} Cancel <-chan struct{}
// ErrResp is the channel that the result of the signature verification // ErrResp is the channel that the result of the signature verification
// is to be sent over. In the see that the signature is valid, a nil // is to be sent over. In the see that the signature is valid, a nil
// error will be passed. Otherwise, a concrete error detailing the // error will be passed. Otherwise, a concrete error detailing the
// issue will be passed. // issue will be passed. This channel MUST be buffered.
ErrResp chan *HtlcIndexErr ErrResp chan *HtlcIndexErr
} }
@ -86,12 +86,13 @@ type SignJob struct {
// transaction being signed. // transaction being signed.
OutputIndex int32 OutputIndex int32
// Cancel is a channel that should be closed if the caller wishes to // Cancel is a channel that is closed by the caller if they wish to
// abandon all pending sign jobs part of a single batch. // abandon all pending sign jobs part of a single batch. This should
Cancel chan struct{} // never be closed by the validator.
Cancel <-chan struct{}
// Resp is the channel that the response to this particular SignJob // Resp is the channel that the response to this particular SignJob
// will be sent over. // will be sent over. This channel MUST be buffered.
// //
// TODO(roasbeef): actually need to allow caller to set, need to retain // TODO(roasbeef): actually need to allow caller to set, need to retain
// order mark commit sig as special // order mark commit sig as special