utils

package
v0.9.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	EventPrefix = "lava_"
)
View Source
const TIMEOUT = 10

Variables

View Source
var (
	TimeoutMutex           = "false"
	TimeoutMutexBoolean, _ = strconv.ParseBool(TimeoutMutex)
)
View Source
var VRFValueAboveReliabilityThresholdError = sdkerrors.New("VRFValueAboveReliabilityThreshold Error", 1, "calculated vrf does not result in a smaller value than threshold") // client could'nt connect to any provider.

Functions

func AppendUniqueIdentifier

func AppendUniqueIdentifier(ctx context.Context, guid uint64) context.Context

func CalculateQueryHash added in v0.4.3

func CalculateQueryHash(relayReq pairingtypes.RelayPrivateData) (queryHash []byte)

func CalculateVrfOnRelay added in v0.4.3

func CalculateVrfOnRelay(request *pairingtypes.RelayPrivateData, response *pairingtypes.RelayReply, vrf_sk vrf.PrivateKey, currentEpoch uint64) ([]byte, []byte)

func Deserialize

func Deserialize(raw []byte, data any)

func FormatDataForVrf added in v0.4.3

func FormatDataForVrf(request *pairingtypes.RelayPrivateData, response *pairingtypes.RelayReply, differentiator bool, currentEpoch uint64) (data []byte)

func FormatStringerList

func FormatStringerList[T fmt.Stringer](description string, listToPrint []T) string

func GeneratePrivateVRFKey added in v0.4.3

func GeneratePrivateVRFKey() (vrf.PrivateKey, vrf.PublicKey, error)

func GenerateUniqueIdentifier

func GenerateUniqueIdentifier() uint64

func GetIndexForVrf added in v0.4.3

func GetIndexForVrf(vrf []byte, providersCount uint32, reliabilityThreshold uint32) (index int64, err error)

func GetUniqueIdentifier

func GetUniqueIdentifier(ctx context.Context) (guid uint64, found bool)

func LavaError added in v0.4.3

func LavaError(ctx sdk.Context, logger log.Logger, name string, attributes map[string]string, description string) error

func LavaFormatDebug

func LavaFormatDebug(description string, attributes ...Attribute) error

func LavaFormatError

func LavaFormatError(description string, err error, attributes ...Attribute) error

func LavaFormatFatal

func LavaFormatFatal(description string, err error, attributes ...Attribute)

func LavaFormatInfo

func LavaFormatInfo(description string, attributes ...Attribute) error

func LavaFormatLog

func LavaFormatLog(description string, err error, attributes []Attribute, severity uint) error

func LavaFormatWarning

func LavaFormatWarning(description string, err error, attributes ...Attribute) error

func LogLavaEvent

func LogLavaEvent(ctx sdk.Context, logger log.Logger, name string, attributes map[string]string, description string)

func LoggingLevel added in v0.4.3

func LoggingLevel(logLevel string)

func OpenKeyring added in v0.4.3

func OpenKeyring(clientCtx client.Context) (keyring.Keyring, error)

func ProveVrfOnRelay added in v0.4.3

func ProveVrfOnRelay(request *pairingtypes.RelayPrivateData, response *pairingtypes.RelayReply, vrf_sk vrf.PrivateKey, differentiator bool, currentEpoch uint64) (vrf_res []byte, proof []byte)

func Serialize

func Serialize(data any) []byte

func VerifyVRF added in v0.4.3

func VerifyVRF(vrfpk string) error

func VerifyVrfProof added in v0.4.3

func VerifyVrfProof(request *pairingtypes.RelayRequest, vrf_pk VrfPubKey, relayEpochStart uint64) (valid bool)

func VerifyVrfProofFromVRFData added in v0.4.3

func VerifyVrfProofFromVRFData(reliabilityData *pairingtypes.VRFData, vrf_pk VrfPubKey, relayEpochStart uint64) (valid bool)

func WithUniqueIdentifier

func WithUniqueIdentifier(ctx context.Context, guid uint64) context.Context

Types

type Attribute

type Attribute struct {
	Key   string
	Value interface{}
}

func LogAttr

func LogAttr(key string, value interface{}) Attribute

type LavaMutex

type LavaMutex struct {
	SecondsLeft int
	// contains filtered or unexported fields
}

func (*LavaMutex) Lock

func (dm *LavaMutex) Lock()

func (*LavaMutex) TryLock

func (dm *LavaMutex) TryLock() (isLocked bool)

func (*LavaMutex) Unlock

func (dm *LavaMutex) Unlock()

type Lockable

type Lockable interface {
	Lock()
	TryLock() bool
	Unlock()
}

type VrfPubKey added in v0.4.3

type VrfPubKey struct {
	// contains filtered or unexported fields
}

func GenerateVRFKey added in v0.4.3

func GenerateVRFKey(clientCtx client.Context) (vrf.PrivateKey, *VrfPubKey, error)

func GetOrCreateVRFKey added in v0.4.3

func GetOrCreateVRFKey(clientCtx client.Context) (sk vrf.PrivateKey, pk *VrfPubKey, err error)

func LoadVRFKey added in v0.4.3

func LoadVRFKey(clientCtx client.Context) (vrf.PrivateKey, *VrfPubKey, error)

func (*VrfPubKey) Bytes added in v0.4.3

func (pk *VrfPubKey) Bytes() []byte

func (*VrfPubKey) DecodeFromBech32 added in v0.4.3

func (pk *VrfPubKey) DecodeFromBech32(bech32str string) (*VrfPubKey, error)

func (*VrfPubKey) EncodeBech32 added in v0.4.3

func (pk *VrfPubKey) EncodeBech32() (string, error)

func (*VrfPubKey) Equals added in v0.4.3

func (pk *VrfPubKey) Equals(pk2 VrfPubKey) bool

func (*VrfPubKey) MarshalTo added in v0.4.3

func (pk *VrfPubKey) MarshalTo(dAtA []byte) (int, error)

// MarshalTo implements proto.Marshaler interface.

func (*VrfPubKey) Reset added in v0.4.3

func (pk *VrfPubKey) Reset()

func (*VrfPubKey) String added in v0.4.3

func (pk *VrfPubKey) String() string

String returns a string representation of the public key

func (*VrfPubKey) Unmarshal added in v0.4.3

func (pk *VrfPubKey) Unmarshal(bz []byte) error

// Unmarshal implements proto.Marshaler interface.

func (*VrfPubKey) VerifySignature added in v0.4.3

func (pk *VrfPubKey) VerifySignature(m []byte, vrfBytes []byte, proof []byte) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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