chain: continue to accept []wire.OutPoint for rescan updates for bitcoind

In this commit, we fix a recently introduced bug that would cause
callers that attempted to get a spend notifications for a particular
outpoint to no longer get that precise notification. In a prior commit,
in preparation for the new neutrino gcs filter format, we added a
mapping from script to outpoint that will be used by neutrino, and later
other backends as well. However, we still need to match on outpoint
slices for bitcoind today.
This commit is contained in:
Olaoluwa Osuntokun 2018-07-17 18:54:20 -07:00
parent fdca047246
commit 6a0e6da280

View file

@ -568,55 +568,65 @@ mainLoop:
// Update our monitored watchlists or do a rescan.
case event := <-c.rescanUpdate:
switch e := event.(type) {
// We're clearing the watchlists.
case struct{}:
// We're clearing the watchlists.
c.clientMtx.Lock()
c.watchAddrs = make(map[string]struct{})
c.watchTxIDs = make(map[chainhash.Hash]struct{})
c.watchOutPoints =
make(map[wire.OutPoint]struct{})
c.clientMtx.Unlock()
// We're updating monitored addresses.
case []btcutil.Address:
// We're updating monitored addresses.
c.clientMtx.Lock()
for _, addr := range e {
c.watchAddrs[addr.EncodeAddress()] =
struct{}{}
}
c.clientMtx.Unlock()
// We're updating monitored outpoints from
// pointers.
case []*wire.OutPoint:
// We're updating monitored outpoints
// from pointers.
c.clientMtx.Lock()
for _, op := range e {
c.watchOutPoints[*op] = struct{}{}
}
c.clientMtx.Unlock()
case []wire.OutPoint:
c.clientMtx.Lock()
for _, op := range e {
c.watchOutPoints[op] = struct{}{}
}
c.clientMtx.Unlock()
// We're updating monitored outpoints that map
// to the scripts that we should scan for.
case map[wire.OutPoint]btcutil.Address:
// We're updating monitored outpoints.
c.clientMtx.Lock()
for op := range e {
c.watchOutPoints[op] = struct{}{}
}
c.clientMtx.Unlock()
// We're adding monitored TXIDs.
case []*chainhash.Hash:
// We're adding monitored TXIDs from
// pointers.
c.clientMtx.Lock()
for _, txid := range e {
c.watchTxIDs[*txid] = struct{}{}
}
c.clientMtx.Unlock()
case []chainhash.Hash:
// We're adding monitored TXIDs.
c.clientMtx.Lock()
for _, txid := range e {
c.watchTxIDs[txid] = struct{}{}
}
c.clientMtx.Unlock()
// We're rescanning from the passed hash.
case *chainhash.Hash:
// We're rescanning from the passed
// hash.
err = c.rescan(e)
if err != nil {
log.Errorf("rescan failed: %s",