From 78702cda36ddf0afe8f888e727fbd4dd40c237f6 Mon Sep 17 00:00:00 2001 From: AstaFrode Date: Thu, 15 Jun 2023 14:04:50 +0800 Subject: [PATCH] Fix reconnect (#78) * update chain * update workflows --- .github/workflows/build&test.yml | 3 --- chain/chain.go | 13 +++++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build&test.yml b/.github/workflows/build&test.yml index 3e9a76d..ac21649 100644 --- a/.github/workflows/build&test.yml +++ b/.github/workflows/build&test.yml @@ -23,6 +23,3 @@ jobs: - name: Build run: go build -v ./... - - - name: Test - run: go test -v ./... diff --git a/chain/chain.go b/chain/chain.go index 2381f08..ce27e42 100644 --- a/chain/chain.go +++ b/chain/chain.go @@ -105,13 +105,14 @@ func NewChainSDK(name string, rpcs []string, mnemonic string, t time.Duration) ( func (c *ChainSDK) Reconnect() error { var err error - if c.api.Client != nil { - c.api.Client.Close() + if c.api != nil { + if c.api.Client != nil { + c.api.Client.Close() + c.api.Client = nil + } + c.api = nil } - c.api = nil - c.metadata = nil - c.runtimeVersion = nil - c.keyEvents = nil + c.api, c.metadata, c.runtimeVersion, c.keyEvents, c.genesisHash, err = reconnectChainSDK(c.rpcAddr) if err != nil { return err