[#1560] morph/client: Perform RPC switch and restore in one step

Otherwise we could switch infinitely if subscription restore has failed.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-06-29 16:02:07 +03:00 committed by fyrchik
parent 6358f4d746
commit 0ccea802e9
4 changed files with 25 additions and 31 deletions

View file

@ -204,16 +204,12 @@ func (c *Client) UnsubscribeAll() error {
// restoreSubscriptions restores subscriptions according to
// cached information about them.
func (c *Client) restoreSubscriptions() bool {
func (c *Client) restoreSubscriptions(endpoint string) bool {
var (
err error
id string
endpoint, _ = c.endpoints.current()
err error
id string
)
c.switchLock.Lock()
defer c.switchLock.Unlock()
// new block events restoration
if c.subscribedToNewBlocks {
_, err = c.client.SubscribeForNewBlocks(nil)