Skip to content

Commit

Permalink
allow setting both height and time offset (cosmos#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilkumarpilli authored Jan 18, 2021
1 parent 93d579f commit d8c752f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
14 changes: 1 addition & 13 deletions cmd/xfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,7 @@ $ %s tx raw send ibc-0 ibc-1 100000stake cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9
}
done()

switch {
case toHeightOffset > 0 && toTimeOffset > 0:
return fmt.Errorf("cannot set both --timeout-height-offset and --timeout-time-offset, choose one")
case toHeightOffset > 0:
return c[src].SendTransferMsg(c[dst], amount, dstAddr, toHeightOffset, 0)
case toTimeOffset > 0:
return c[src].SendTransferMsg(c[dst], amount, dstAddr, 0, toTimeOffset)
case toHeightOffset == 0 && toTimeOffset == 0:
return c[src].SendTransferMsg(c[dst], amount, dstAddr, 0, 0)
default:
return fmt.Errorf("shouldn't be here")
}

return c[src].SendTransferMsg(c[dst], amount, dstAddr, toHeightOffset, toTimeOffset)
},
}
return timeoutFlags(pathFlag(cmd))
Expand Down
3 changes: 2 additions & 1 deletion relayer/packet-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringe

switch {
case toHeightOffset > 0 && toTimeOffset > 0:
return fmt.Errorf("cant set both timeout height and time offset")
timeoutHeight = uint64(h.Header.Height) + toHeightOffset
timeoutTimestamp = uint64(time.Now().Add(toTimeOffset).UnixNano())
case toHeightOffset > 0:
timeoutHeight = uint64(h.Header.Height) + toHeightOffset
timeoutTimestamp = 0
Expand Down

0 comments on commit d8c752f

Please sign in to comment.