chainntnfs: remove mempool option from RegisterSpendNtfn
This commit is contained in:
parent
77f0020697
commit
44d7b84df0
@ -7,7 +7,6 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/btcsuite/btcd/btcjson"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
@ -16,6 +15,7 @@ import (
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwallet/chain"
|
||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -367,11 +367,9 @@ func (b *BitcoindNotifier) handleRelevantTx(tx chain.RelevantTx, bestHeight int3
|
||||
// the spend within a block.
|
||||
rem := make(map[uint64]*spendNotification)
|
||||
for c, ntfn := range clients {
|
||||
// If this is a mempool spend,
|
||||
// and this client didn't want
|
||||
// to be notified on mempool
|
||||
// spends, store it for later.
|
||||
if !confirmedSpend && !ntfn.mempool {
|
||||
// If this is a mempool spend, store the client
|
||||
// to wait for a confirmed spend.
|
||||
if !confirmedSpend {
|
||||
rem[c] = ntfn
|
||||
continue
|
||||
}
|
||||
@ -560,8 +558,6 @@ type spendNotification struct {
|
||||
spendID uint64
|
||||
|
||||
heightHint uint32
|
||||
|
||||
mempool bool
|
||||
}
|
||||
|
||||
// spendCancel is a message sent to the BitcoindNotifier when a client wishes
|
||||
@ -580,13 +576,12 @@ type spendCancel struct {
|
||||
// across the 'Spend' channel. The heightHint should represent the earliest
|
||||
// height in the chain where the transaction could have been spent in.
|
||||
func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
heightHint uint32, mempool bool) (*chainntnfs.SpendEvent, error) {
|
||||
heightHint uint32) (*chainntnfs.SpendEvent, error) {
|
||||
|
||||
ntfn := &spendNotification{
|
||||
targetOutpoint: outpoint,
|
||||
spendChan: make(chan *chainntnfs.SpendDetail, 1),
|
||||
spendID: atomic.AddUint64(&b.spendClientCounter, 1),
|
||||
mempool: mempool,
|
||||
}
|
||||
|
||||
select {
|
||||
|
@ -416,10 +416,9 @@ out:
|
||||
rem := make(map[uint64]*spendNotification)
|
||||
for c, ntfn := range clients {
|
||||
// If this is a mempool spend,
|
||||
// and this client didn't want
|
||||
// to be notified on mempool
|
||||
// spends, store it for later.
|
||||
if !confirmedSpend && !ntfn.mempool {
|
||||
// store the client to wait for
|
||||
// a confirmed spend.
|
||||
if !confirmedSpend {
|
||||
rem[c] = ntfn
|
||||
continue
|
||||
}
|
||||
@ -673,8 +672,6 @@ type spendNotification struct {
|
||||
|
||||
spendID uint64
|
||||
|
||||
mempool bool
|
||||
|
||||
heightHint uint32
|
||||
}
|
||||
|
||||
@ -694,14 +691,13 @@ type spendCancel struct {
|
||||
// across the 'Spend' channel. The heightHint should represent the earliest
|
||||
// height in the chain where the transaction could have been spent in.
|
||||
func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
heightHint uint32, mempool bool) (*chainntnfs.SpendEvent, error) {
|
||||
heightHint uint32) (*chainntnfs.SpendEvent, error) {
|
||||
|
||||
ntfn := &spendNotification{
|
||||
targetOutpoint: outpoint,
|
||||
spendChan: make(chan *chainntnfs.SpendDetail, 1),
|
||||
spendID: atomic.AddUint64(&b.spendClientCounter, 1),
|
||||
heightHint: heightHint,
|
||||
mempool: mempool,
|
||||
}
|
||||
|
||||
select {
|
||||
|
@ -43,15 +43,13 @@ type ChainNotifier interface {
|
||||
// The heightHint denotes the earliest height in the blockchain in
|
||||
// which the target output could have been created.
|
||||
//
|
||||
// NOTE: If mempool=true is set, then this notification should be
|
||||
// triggered on a best-effort basis once the transaction is *seen* on
|
||||
// the network. If mempool=false, it should only be triggered when the
|
||||
// spending transaction receives a single confirmation.
|
||||
// NOTE: The notification should only be triggered when the spending
|
||||
// transaction receives a single confirmation.
|
||||
//
|
||||
// NOTE: Dispatching notifications to multiple clients subscribed to a
|
||||
// spend of the same outpoint MUST be supported.
|
||||
RegisterSpendNtfn(outpoint *wire.OutPoint, heightHint uint32,
|
||||
mempool bool) (*SpendEvent, error)
|
||||
RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
heightHint uint32) (*SpendEvent, error)
|
||||
|
||||
// RegisterBlockEpochNtfn registers an intent to be notified of each
|
||||
// new block connected to the tip of the main chain. The returned
|
||||
|
@ -566,7 +566,7 @@ type spendCancel struct {
|
||||
// target outpoint has been detected, the details of the spending event will be
|
||||
// sent across the 'Spend' channel.
|
||||
func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
heightHint uint32, _ bool) (*chainntnfs.SpendEvent, error) {
|
||||
heightHint uint32) (*chainntnfs.SpendEvent, error) {
|
||||
|
||||
n.heightMtx.RLock()
|
||||
currentHeight := n.bestHeight
|
||||
|
Loading…
Reference in New Issue
Block a user