Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Merge PR #78: Add variables needed in retries
Browse files Browse the repository at this point in the history
* removing these in the provider package in the relayer so need to add them in lens for use in provider imp

* add MustGetHeight
  • Loading branch information
jtieri authored Jan 24, 2022
1 parent 343af99 commit ce88e62
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ var (
toHeightTag = "packet_timeout_height"
toTSTag = "packet_timeout_timestamp"
seqTag = "packet_sequence"

RtyAttNum = uint(5)
RtyAtt = retry.Attempts(RtyAttNum)
RtyDel = retry.Delay(time.Millisecond * 400)
RtyErr = retry.LastErrorOnly(true)
)

type CosmosMessage struct {
Expand Down Expand Up @@ -654,7 +659,7 @@ func (cc *ChainClient) InjectTrustedFields(header ibcexported.Header, dst provid
}
trustedHeader = th
return err
}, provider.RtyAtt, provider.RtyDel, provider.RtyErr); err != nil {
}, RtyAtt, RtyDel, RtyErr); err != nil {
return nil, fmt.Errorf(
"failed to get trusted header, please ensure header at the height %d has not been pruned by the connected node: %w",
h.TrustedHeight.RevisionHeight, err,
Expand Down Expand Up @@ -1160,7 +1165,7 @@ func (cc *ChainClient) AutoUpdateClient(dst provider.ChainProvider, thresholdTim
cc.Log(fmt.Sprintf("★ Client updated: [%s]client(%s) {%d}->{%d}",
cc.Config.ChainID,
srcClientId,
provider.MustGetHeight(srcUpdateHeader.GetHeight()),
MustGetHeight(srcUpdateHeader.GetHeight()),
srcUpdateHeader.GetHeight().GetRevisionHeight(),
))

Expand Down Expand Up @@ -1363,3 +1368,12 @@ func (cc *ChainClient) WaitForNBlocks(n int64) error {
time.Sleep(10 * time.Millisecond)
}
}

// MustGetHeight takes the height inteface and returns the actual height
func MustGetHeight(h ibcexported.Height) clienttypes.Height {
height, ok := h.(clienttypes.Height)
if !ok {
panic("height is not an instance of height!")
}
return height
}

0 comments on commit ce88e62

Please sign in to comment.