-
Notifications
You must be signed in to change notification settings - Fork 557
/
params.go
37 lines (30 loc) · 1.24 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package types
import (
"time"
errorsmod "cosmossdk.io/errors"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
)
// DefaultTimeout defines a default parameter for the channel upgrade protocol.
// It allows relayers a window in which they can flush all in-flight packets on a channel before completing the upgrade handshake.
// This parameter can be overridden by a valid authority using the UpdateChannelParams rpc.
var DefaultTimeout = NewTimeout(clienttypes.ZeroHeight(), uint64(10*time.Minute.Nanoseconds()))
// NewParams creates a new parameter configuration for the channel submodule
func NewParams(upgradeTimeout Timeout) Params {
return Params{
UpgradeTimeout: upgradeTimeout,
}
}
// DefaultParams is the default parameter configuration for the channel submodule
func DefaultParams() Params {
return NewParams(DefaultTimeout)
}
// Validate the params.
func (p Params) Validate() error {
if !p.UpgradeTimeout.Height.IsZero() {
return errorsmod.Wrapf(ErrInvalidUpgradeTimeout, "upgrade timeout height must be zero. got : %v", p.UpgradeTimeout.Height)
}
if p.UpgradeTimeout.Timestamp == 0 {
return errorsmod.Wrapf(ErrInvalidUpgradeTimeout, "upgrade timeout timestamp invalid: %v", p.UpgradeTimeout.Timestamp)
}
return nil
}