Skip to content

Commit

Permalink
Merge branch 'main' into ont
Browse files Browse the repository at this point in the history
  • Loading branch information
devfans committed Sep 23, 2021
2 parents 34a5456 + 17da606 commit 4bc1bb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 9 additions & 4 deletions chains/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package chains

import (
"context"
"fmt"
"strings"
"sync"
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
}
}

Expand Down
7 changes: 1 addition & 6 deletions wallet/poly.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 4bc1bb1

Please sign in to comment.