common

package
v0.27.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointsConfigName                = "endpoints"
	SaveConfigFlagName                 = "save-conf"
	GeolocationFlag                    = "geolocation"
	TestModeFlagName                   = "test-mode"
	MaximumConcurrentProvidersFlagName = "concurrent-providers"
	StatusCodeMetadataKey              = "status-code"
	VersionMetadataKey                 = "lavap-version"
)
View Source
const (
	URL_QUERY_PARAMETERS_SEPARATOR_FROM_PATH        = "?"
	URL_QUERY_PARAMETERS_SEPARATOR_OTHER_PARAMETERS = "&"
	IP_FORWARDING_HEADER_NAME                       = "X-Forwarded-For"
	PROVIDER_ADDRESS_HEADER_NAME                    = "Lava-Provider-Address"
)
View Source
const (
	TimePerCU                      = uint64(100 * time.Millisecond)
	MinimumTimePerRelayDelay       = time.Second
	DataReliabilityTimeoutIncrease = 5 * time.Second
	AverageWorldLatency            = 300 * time.Millisecond
)

Variables

View Source
var (
	ContextDeadlineExceededError = sdkerrors.New("ContextDeadlineExceeded Error", 300, "context deadline exceeded")
	StatusCodeError504           = sdkerrors.New("Disallowed StatusCode Error", 504, "Disallowed status code error")
	StatusCodeError429           = sdkerrors.New("Disallowed StatusCode Error", 429, "Disallowed status code error")
	StatusCodeErrorStrict        = sdkerrors.New("Disallowed StatusCode Error", 800, "Disallowed status code error")
)

Functions

func BaseTimePerCU

func BaseTimePerCU(cu uint64) time.Duration

func ContextOutOfTime

func ContextOutOfTime(ctx context.Context) bool

func FindSequenceNumber

func FindSequenceNumber(sequence string) (int, error)

extract requested sequence number from tx error.

func GetExtensionNames

func GetExtensionNames(extensionCollection []*spectypes.Extension) (extensions []string)

func GetIpFromGrpcContext

func GetIpFromGrpcContext(ctx context.Context) string

func GetRemainingTimeoutFromContext

func GetRemainingTimeoutFromContext(ctx context.Context) (timeRemaining time.Duration)

func GetTimePerCu

func GetTimePerCu(cu uint64) time.Duration

func GetTokenFromGrpcContext

func GetTokenFromGrpcContext(ctx context.Context) string

func GetUniqueToken

func GetUniqueToken(consumerAddress string, ip string) string

func IsTestMode

func IsTestMode(ctx context.Context) bool

func IsTimeout

func IsTimeout(errArg error) bool

func LocalNodeTimePerCu

func LocalNodeTimePerCu(cu uint64) time.Duration

func LowerContextTimeout added in v0.9.3

func LowerContextTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

func ParseEndpointArgs

func ParseEndpointArgs(endpoint_strings, yaml_config_properties []string, endpointsConfigName string) (viper_endpoints *viper.Viper, err error)

func ValidateEndpoint

func ValidateEndpoint(endpoint, apiInterface string) error

func VerifyAndHandleUnsupportedFlags

func VerifyAndHandleUnsupportedFlags(currentFlags *pflag.FlagSet) error

Types

type AuthConfig

type AuthConfig struct {
	AuthHeaders map[string]string `yaml:"auth-headers,omitempty" json:"auth-headers,omitempty" mapstructure:"auth-headers"`
	AuthQuery   string            `yaml:"auth-query,omitempty" json:"auth-query,omitempty" mapstructure:"auth-query"`
	UseTLS      bool              `yaml:"use-tls,omitempty" json:"use-tls,omitempty" mapstructure:"use-tls"`
	KeyPem      string            `yaml:"key-pem,omitempty" json:"key-pem,omitempty" mapstructure:"key-pem"`
	CertPem     string            `yaml:"cert-pem,omitempty" json:"cert-pem,omitempty" mapstructure:"cert-pem"`
	CaCert      string            `yaml:"cacert-pem,omitempty" json:"cacert-pem,omitempty" mapstructure:"cacert-pem"`
}

func (*AuthConfig) AddAuthPath

func (ac *AuthConfig) AddAuthPath(url string) string

func (*AuthConfig) GetCaCertificateParams

func (ac *AuthConfig) GetCaCertificateParams() string

File containing trusted root certificates for verifying the server.

func (*AuthConfig) GetLoadingCertificateParams

func (ac *AuthConfig) GetLoadingCertificateParams() (string, string)

File containing client certificate (public key), to present to the server. + File containing client private key, to present to the server.

func (*AuthConfig) GetUseTls

func (ac *AuthConfig) GetUseTls() bool

type ConflictHandlerInterface

type ConflictHandlerInterface interface {
	ConflictAlreadyReported() bool
	StoreConflictReported()
}

type NodeUrl

type NodeUrl struct {
	Url          string        `yaml:"url,omitempty" json:"url,omitempty" mapstructure:"url"`
	InternalPath string        `yaml:"internal-path,omitempty" json:"internal-path,omitempty" mapstructure:"internal-path"`
	AuthConfig   AuthConfig    `yaml:"auth-config,omitempty" json:"auth-config,omitempty" mapstructure:"auth-config"`
	IpForwarding bool          `yaml:"ip-forwarding,omitempty" json:"ip-forwarding,omitempty" mapstructure:"ip-forwarding"`
	Timeout      time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" mapstructure:"timeout"`
	Addons       []string      `yaml:"addons,omitempty" json:"addons,omitempty" mapstructure:"addons"`
}

func (*NodeUrl) LowerContextTimeout

func (url *NodeUrl) LowerContextTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

func (*NodeUrl) SetAuthHeaders

func (url *NodeUrl) SetAuthHeaders(ctx context.Context, headerSetter func(string, string))

func (*NodeUrl) SetIpForwardingIfNecessary

func (url *NodeUrl) SetIpForwardingIfNecessary(ctx context.Context, headerSetter func(string, string))

func (NodeUrl) String

func (nurl NodeUrl) String() string

func (*NodeUrl) UrlStr

func (nurl *NodeUrl) UrlStr() string

type RelayResult

type RelayResult struct {
	Request         *pairingtypes.RelayRequest
	Reply           *pairingtypes.RelayReply
	ProviderAddress string
	ReplyServer     *pairingtypes.Relayer_RelaySubscribeClient
	Finalized       bool
	ConflictHandler ConflictHandlerInterface
	StatusCode      int
}

func (*RelayResult) GetProvider

func (rr *RelayResult) GetProvider() string

func (*RelayResult) GetReply

func (rr *RelayResult) GetReply() *pairingtypes.RelayReply

func (*RelayResult) GetReplyServer

func (*RelayResult) GetStatusCode

func (rr *RelayResult) GetStatusCode() int

type Test_mode_ctx_key

type Test_mode_ctx_key struct{}

type TxResultData

type TxResultData struct {
	RawLog string
	Txhash []byte
	Code   int
}

func ParseTransactionResult

func ParseTransactionResult(parsedValues map[string]any) (retData TxResultData, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL