Do not reissue rescan requests on reconnect.
This commit is contained in:
parent
cfb46e2c43
commit
4ac778d72a
2 changed files with 31 additions and 2 deletions
|
@ -474,6 +474,12 @@ func (c *Client) reregisterNtfns() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignoreResends is a set of all methods for requests that are "long running"
|
||||||
|
// are not be reissued by the client on reconnect.
|
||||||
|
var ignoreResends = map[string]struct{}{
|
||||||
|
"rescan": struct{}{},
|
||||||
|
}
|
||||||
|
|
||||||
// resendCmds resends any commands that had not completed when the client
|
// resendCmds resends any commands that had not completed when the client
|
||||||
// disconnected. It is intended to be called once the client has reconnected as
|
// disconnected. It is intended to be called once the client has reconnected as
|
||||||
// a separate goroutine.
|
// a separate goroutine.
|
||||||
|
@ -492,9 +498,20 @@ func (c *Client) resendCmds() {
|
||||||
// also allows the lock to be released quickly.
|
// also allows the lock to be released quickly.
|
||||||
c.requestLock.Lock()
|
c.requestLock.Lock()
|
||||||
resendCmds := make([]*jsonRequest, 0, c.requestList.Len())
|
resendCmds := make([]*jsonRequest, 0, c.requestList.Len())
|
||||||
for e := c.requestList.Front(); e != nil; e = e.Next() {
|
var nextElem *list.Element
|
||||||
|
for e := c.requestList.Front(); e != nil; e = nextElem {
|
||||||
|
nextElem = e.Next()
|
||||||
|
|
||||||
req := e.Value.(*jsonRequest)
|
req := e.Value.(*jsonRequest)
|
||||||
resendCmds = append(resendCmds, req)
|
if _, ok := ignoreResends[req.cmd.Method()]; ok {
|
||||||
|
// If a request is not sent on reconnect, remove it
|
||||||
|
// from the request structures, since no reply is
|
||||||
|
// expected.
|
||||||
|
delete(c.requestMap, req.cmd.Id().(uint64))
|
||||||
|
c.requestList.Remove(e)
|
||||||
|
} else {
|
||||||
|
resendCmds = append(resendCmds, req)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.requestLock.Unlock()
|
c.requestLock.Unlock()
|
||||||
|
|
||||||
|
|
12
notify.go
12
notify.go
|
@ -897,6 +897,12 @@ func (r FutureRescanResult) Receive() error {
|
||||||
//
|
//
|
||||||
// See Rescan for the blocking version and more details.
|
// See Rescan for the blocking version and more details.
|
||||||
//
|
//
|
||||||
|
// NOTE: Rescan requests are not issued on client reconnect and must be
|
||||||
|
// performed manually (ideally with a new start height based on the last
|
||||||
|
// rescan progress notification). See the OnClientConnected notification
|
||||||
|
// callback for a good callsite to reissue rescan requests on connect and
|
||||||
|
// reconnect.
|
||||||
|
//
|
||||||
// NOTE: This is a btcd extension and requires a websocket connection.
|
// NOTE: This is a btcd extension and requires a websocket connection.
|
||||||
func (c *Client) RescanAsync(startHeight int32, addresses []btcutil.Address,
|
func (c *Client) RescanAsync(startHeight int32, addresses []btcutil.Address,
|
||||||
outpoints []*btcwire.OutPoint) FutureRescanResult {
|
outpoints []*btcwire.OutPoint) FutureRescanResult {
|
||||||
|
@ -952,6 +958,12 @@ func (c *Client) RescanAsync(startHeight int32, addresses []btcutil.Address,
|
||||||
// See RescanEndHeight to also specify a block height at which to stop the
|
// See RescanEndHeight to also specify a block height at which to stop the
|
||||||
// rescan if a bounded rescan is desired instead.
|
// rescan if a bounded rescan is desired instead.
|
||||||
//
|
//
|
||||||
|
// NOTE: Rescan requests are not issued on client reconnect and must be
|
||||||
|
// performed manually (ideally with a new start height based on the last
|
||||||
|
// rescan progress notification). See the OnClientConnected notification
|
||||||
|
// callback for a good callsite to reissue rescan requests on connect and
|
||||||
|
// reconnect.
|
||||||
|
//
|
||||||
// NOTE: This is a btcd extension and requires a websocket connection.
|
// NOTE: This is a btcd extension and requires a websocket connection.
|
||||||
func (c *Client) Rescan(startHeight int32, addresses []btcutil.Address,
|
func (c *Client) Rescan(startHeight int32, addresses []btcutil.Address,
|
||||||
outpoints []*btcwire.OutPoint) error {
|
outpoints []*btcwire.OutPoint) error {
|
||||||
|
|
Loading…
Reference in a new issue