Skip to content

Commit

Permalink
Add GetTrustedHeader (#390)
Browse files Browse the repository at this point in the history
* funcion added

* GetTrustedHeader added
  • Loading branch information
NagaTulasi authored Feb 2, 2021
1 parent b1360ef commit cbedb3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 5 additions & 5 deletions relayer/client-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (c *Chain) UpdateClients(dst *Chain) (err error) {
return nil
}

// UpgradesClients upgrades the client on src after dst chain has undergone an upgrade.
// UpgradeClients upgrades the client on src after dst chain has undergone an upgrade.
func (c *Chain) UpgradeClients(dst *Chain, height int64) error {
sh, err := NewSyncHeaders(c, dst)
if err != nil {
Expand All @@ -211,10 +211,10 @@ func (c *Chain) UpgradeClients(dst *Chain, height int64) error {
height = int64(sh.GetHeight(dst.ChainID))
}

// TODO: construct method of only attempting to get dst header
// Note: we explicitly do not check the error since the source
// trusted header will fail
_, dstUpdateHeader, _ := sh.GetTrustedHeaders(c, dst)
dstUpdateHeader, err := sh.GetTrustedHeader(dst, c)
if err != nil {
return err
}

// query proofs on counterparty
clientState, proofUpgradeClient, _, err := dst.QueryUpgradedClient(height)
Expand Down
11 changes: 11 additions & 0 deletions relayer/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ func (uh *SyncHeaders) GetTrustedHeaders(src, dst *Chain) (srcTh, dstTh *tmclien
return
}

// GetTrustedHeader returns given chain ID's trusted header
func (uh *SyncHeaders) GetTrustedHeader(src, dst *Chain) (header *tmclient.Header, err error) {
eg := new(errgroup.Group)
eg.Go(func() error {
header, err = InjectTrustedFields(src, dst, uh.GetHeader(src.ChainID))
return err
})
err = eg.Wait()
return
}

// InjectTrustedFields injects the necessary trusted fields for a srcHeader coming from a srcChain
// destined for an IBC client stored on the dstChain
// TrustedHeight is the latest height of the IBC client on dstChain
Expand Down

0 comments on commit cbedb3c

Please # to comment.