mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 13:42:49 +02:00
chainntnfs: export NotifierOptions and internal field for interface use
Export NotifierOptions and its internal field to enable external satisfaction of the protofsm.DaemonAdapters interface.
This commit is contained in:
@@ -70,28 +70,28 @@ func (t TxConfStatus) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// notifierOptions is a set of functional options that allow callers to further
|
// NotifierOptions is a set of functional options that allow callers to further
|
||||||
// modify the type of chain event notifications they receive.
|
// modify the type of chain event notifications they receive.
|
||||||
type notifierOptions struct {
|
type NotifierOptions struct {
|
||||||
// includeBlock if true, then the dispatched confirmation notification
|
// IncludeBlock if true, then the dispatched confirmation notification
|
||||||
// will include the block that mined the transaction.
|
// will include the block that mined the transaction.
|
||||||
includeBlock bool
|
IncludeBlock bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultNotifierOptions returns the set of default options for the notifier.
|
// DefaultNotifierOptions returns the set of default options for the notifier.
|
||||||
func defaultNotifierOptions() *notifierOptions {
|
func DefaultNotifierOptions() *NotifierOptions {
|
||||||
return ¬ifierOptions{}
|
return &NotifierOptions{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifierOption is a functional option that allows a caller to modify the
|
// NotifierOption is a functional option that allows a caller to modify the
|
||||||
// events received from the notifier.
|
// events received from the notifier.
|
||||||
type NotifierOption func(*notifierOptions)
|
type NotifierOption func(*NotifierOptions)
|
||||||
|
|
||||||
// WithIncludeBlock is an optional argument that allows the calelr to specify
|
// WithIncludeBlock is an optional argument that allows the caller to specify
|
||||||
// that the block that mined a transaction should be included in the response.
|
// that the block that mined a transaction should be included in the response.
|
||||||
func WithIncludeBlock() NotifierOption {
|
func WithIncludeBlock() NotifierOption {
|
||||||
return func(o *notifierOptions) {
|
return func(o *NotifierOptions) {
|
||||||
o.includeBlock = true
|
o.IncludeBlock = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -559,7 +559,7 @@ func NewTxNotifier(startHeight uint32, reorgSafetyLimit uint32,
|
|||||||
// and register a confirmation notification.
|
// and register a confirmation notification.
|
||||||
func (n *TxNotifier) newConfNtfn(txid *chainhash.Hash,
|
func (n *TxNotifier) newConfNtfn(txid *chainhash.Hash,
|
||||||
pkScript []byte, numConfs, heightHint uint32,
|
pkScript []byte, numConfs, heightHint uint32,
|
||||||
opts *notifierOptions) (*ConfNtfn, error) {
|
opts *NotifierOptions) (*ConfNtfn, error) {
|
||||||
|
|
||||||
// An accompanying output script must always be provided.
|
// An accompanying output script must always be provided.
|
||||||
if len(pkScript) == 0 {
|
if len(pkScript) == 0 {
|
||||||
@@ -593,7 +593,7 @@ func (n *TxNotifier) newConfNtfn(txid *chainhash.Hash,
|
|||||||
n.CancelConf(confRequest, confID)
|
n.CancelConf(confRequest, confID)
|
||||||
}),
|
}),
|
||||||
HeightHint: heightHint,
|
HeightHint: heightHint,
|
||||||
includeBlock: opts.includeBlock,
|
includeBlock: opts.IncludeBlock,
|
||||||
numConfsLeft: numConfs,
|
numConfsLeft: numConfs,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -616,7 +616,7 @@ func (n *TxNotifier) RegisterConf(txid *chainhash.Hash, pkScript []byte,
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := defaultNotifierOptions()
|
opts := DefaultNotifierOptions()
|
||||||
for _, optFunc := range optFuncs {
|
for _, optFunc := range optFuncs {
|
||||||
optFunc(opts)
|
optFunc(opts)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user