chainntnfs: add unique ID field to track conf ntfns within notifier
This commit is contained in:
parent
ad904ebe8c
commit
c43506dee9
@ -54,6 +54,7 @@ type chainUpdate struct {
|
||||
// chain client. Multiple concurrent clients are supported. All notifications
|
||||
// are achieved via non-blocking sends on client channels.
|
||||
type BitcoindNotifier struct {
|
||||
confClientCounter uint64 // To be used atomically.
|
||||
spendClientCounter uint64 // To be used atomically.
|
||||
epochClientCounter uint64 // To be used atomically.
|
||||
|
||||
@ -716,6 +717,7 @@ func (b *BitcoindNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||
|
||||
ntfn := &confirmationNotification{
|
||||
ConfNtfn: chainntnfs.ConfNtfn{
|
||||
ConfID: atomic.AddUint64(&b.confClientCounter, 1),
|
||||
TxID: txid,
|
||||
NumConfirmations: numConfs,
|
||||
Event: chainntnfs.NewConfirmationEvent(numConfs),
|
||||
|
@ -61,6 +61,7 @@ type txUpdate struct {
|
||||
// notifications. Multiple concurrent clients are supported. All notifications
|
||||
// are achieved via non-blocking sends on client channels.
|
||||
type BtcdNotifier struct {
|
||||
confClientCounter uint64 // To be used aotmically.
|
||||
spendClientCounter uint64 // To be used atomically.
|
||||
epochClientCounter uint64 // To be used atomically.
|
||||
|
||||
@ -800,6 +801,7 @@ func (b *BtcdNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||
|
||||
ntfn := &confirmationNotification{
|
||||
ConfNtfn: chainntnfs.ConfNtfn{
|
||||
ConfID: atomic.AddUint64(&b.confClientCounter, 1),
|
||||
TxID: txid,
|
||||
NumConfirmations: numConfs,
|
||||
Event: chainntnfs.NewConfirmationEvent(numConfs),
|
||||
|
@ -48,12 +48,13 @@ var (
|
||||
// TODO(roasbeef): heavily consolidate with NeutrinoNotifier code
|
||||
// * maybe combine into single package?
|
||||
type NeutrinoNotifier struct {
|
||||
started int32 // To be used atomically.
|
||||
stopped int32 // To be used atomically.
|
||||
|
||||
confClientCounter uint64 // To be used atomically.
|
||||
spendClientCounter uint64 // To be used atomically.
|
||||
epochClientCounter uint64 // To be used atomically.
|
||||
|
||||
started int32 // To be used atomically.
|
||||
stopped int32 // To be used atomically.
|
||||
|
||||
heightMtx sync.RWMutex
|
||||
bestHeight uint32
|
||||
|
||||
@ -696,6 +697,7 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||
|
||||
ntfn := &confirmationsNotification{
|
||||
ConfNtfn: chainntnfs.ConfNtfn{
|
||||
ConfID: atomic.AddUint64(&n.confClientCounter, 1),
|
||||
TxID: txid,
|
||||
NumConfirmations: numConfs,
|
||||
Event: chainntnfs.NewConfirmationEvent(numConfs),
|
||||
|
@ -18,6 +18,10 @@ var (
|
||||
// once the target transaction gets sufficient confirmations. The client is
|
||||
// asynchronously notified via the ConfirmationEvent channels.
|
||||
type ConfNtfn struct {
|
||||
// ConfID uniquely identifies the confirmation notification request for
|
||||
// the specified transaction.
|
||||
ConfID uint64
|
||||
|
||||
// TxID is the hash of the transaction for which confirmation notifications
|
||||
// are requested.
|
||||
TxID *chainhash.Hash
|
||||
@ -72,7 +76,7 @@ type TxConfNotifier struct {
|
||||
|
||||
// confNotifications is an index of notification requests by transaction
|
||||
// hash.
|
||||
confNotifications map[chainhash.Hash][]*ConfNtfn
|
||||
confNotifications map[chainhash.Hash]map[uint64]*ConfNtfn
|
||||
|
||||
// txsByInitialHeight is an index of watched transactions by the height
|
||||
// that they are included at in the blockchain. This is tracked so that
|
||||
@ -95,7 +99,7 @@ func NewTxConfNotifier(startHeight uint32, reorgSafetyLimit uint32) *TxConfNotif
|
||||
return &TxConfNotifier{
|
||||
currentHeight: startHeight,
|
||||
reorgSafetyLimit: reorgSafetyLimit,
|
||||
confNotifications: make(map[chainhash.Hash][]*ConfNtfn),
|
||||
confNotifications: make(map[chainhash.Hash]map[uint64]*ConfNtfn),
|
||||
txsByInitialHeight: make(map[uint32]map[chainhash.Hash]struct{}),
|
||||
ntfnsByConfirmHeight: make(map[uint32]map[*ConfNtfn]struct{}),
|
||||
quit: make(chan struct{}),
|
||||
|
Loading…
Reference in New Issue
Block a user