From 21009fa73fc0be8e81de11e5583063a4ab1f469c Mon Sep 17 00:00:00 2001 From: Stefan Liu Date: Wed, 22 Sep 2021 16:26:04 +0800 Subject: [PATCH 1/3] Add polygon heimdall chain name --- base/base.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/base.go b/base/base.go index 5c1d10c..036bdcc 100644 --- a/base/base.go +++ b/base/base.go @@ -86,6 +86,8 @@ func GetChainName(id uint64) string { return "OK" case MATIC: return "Polygon" + case HEIMDALL: + return "Heimdall" case NEO3: return "NEO3" case SWITCHEO: From db804541c77e89d1115aa17e0f1f425acbe6023d Mon Sep 17 00:00:00 2001 From: Stefan Liu Date: Thu, 23 Sep 2021 10:33:35 +0800 Subject: [PATCH 2/3] Sink upstream context into WaitTillHeight --- chains/chain.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/chains/chain.go b/chains/chain.go index e932d2b..cd3fe94 100644 --- a/chains/chain.go +++ b/chains/chain.go @@ -18,6 +18,7 @@ package chains import ( + "context" "fmt" "strings" "sync" @@ -44,7 +45,7 @@ type SDK interface { type Nodes interface { Height() uint64 - WaitTillHeight(uint64, time.Duration) uint64 + WaitTillHeight(context.Context, uint64, time.Duration) (uint64, bool) Available() bool Node() SDK } @@ -77,7 +78,7 @@ func (s *ChainSDK) Height() uint64 { return s.height } -func (s *ChainSDK) WaitTillHeight(height uint64, interval time.Duration) uint64 { +func (s *ChainSDK) WaitTillHeight(ctx context.Context, height uint64, interval time.Duration) (uint64, bool) { if interval == 0 { interval = s.interval } @@ -86,9 +87,13 @@ func (s *ChainSDK) WaitTillHeight(height uint64, interval time.Duration) uint64 if err != nil { log.Error("Failed to get chain latest height err ", "chain", s.ChainID, "err", err) } else if h >= height { - return h + return h, true + } + select { + case <-ctx.Done(): + return h, false + case <-time.After(interval): } - time.Sleep(interval) } } From 17da6069548a1d575846ba1addbc514910793500 Mon Sep 17 00:00:00 2001 From: Stefan Liu Date: Thu, 23 Sep 2021 11:17:07 +0800 Subject: [PATCH 3/3] Remove PolySignerConfig --- wallet/poly.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/wallet/poly.go b/wallet/poly.go index d62ef9f..d7824ad 100644 --- a/wallet/poly.go +++ b/wallet/poly.go @@ -23,12 +23,7 @@ import ( sdk "github.com/polynetwork/poly-go-sdk" ) -type PolySignerConfig struct { - Path string - Password string -} - -func NewPolySigner(config *PolySignerConfig) (signer *sdk.Account, err error) { +func NewPolySigner(config *Config) (signer *sdk.Account, err error) { if config == nil { return nil, fmt.Errorf("Missing poly wallet config") }