MCPcopy Create free account
hub / github.com/tendermint/tendermint / ValidateBasic

Method ValidateBasic

config/config.go:1020–1069  ·  view source on GitHub ↗

ValidateBasic performs basic validation.

()

Source from the content-addressed store, hash-verified

1018
1019// ValidateBasic performs basic validation.
1020func (cfg *StateSyncConfig) ValidateBasic() error {
1021 if !cfg.Enable {
1022 return nil
1023 }
1024
1025 // If we're not using the P2P stack then we need to validate the
1026 // RPCServers
1027 if !cfg.UseP2P {
1028 if len(cfg.RPCServers) < 2 {
1029 return errors.New("at least two rpc-servers must be specified")
1030 }
1031
1032 for _, server := range cfg.RPCServers {
1033 if server == "" {
1034 return errors.New("found empty rpc-servers entry")
1035 }
1036 }
1037 }
1038
1039 if cfg.DiscoveryTime != 0 && cfg.DiscoveryTime < 5*time.Second {
1040 return errors.New("discovery time must be 0s or greater than five seconds")
1041 }
1042
1043 if cfg.TrustPeriod <= 0 {
1044 return errors.New("trusted-period is required")
1045 }
1046
1047 if cfg.TrustHeight <= 0 {
1048 return errors.New("trusted-height is required")
1049 }
1050
1051 if len(cfg.TrustHash) == 0 {
1052 return errors.New("trusted-hash is required")
1053 }
1054
1055 _, err := hex.DecodeString(cfg.TrustHash)
1056 if err != nil {
1057 return fmt.Errorf("invalid trusted-hash: %w", err)
1058 }
1059
1060 if cfg.ChunkRequestTimeout < 5*time.Second {
1061 return errors.New("chunk-request-timeout must be at least 5 seconds")
1062 }
1063
1064 if cfg.Fetchers <= 0 {
1065 return errors.New("fetchers is required")
1066 }
1067
1068 return nil
1069}
1070
1071//-----------------------------------------------------------------------------
1072

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected