utils

package
v0.0.0-...-8c29382 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainIdMainnet  = "kyve-1"
	ChainIdKaon     = "kaon-1"
	ChainIdKorellia = "korellia-2"

	RestEndpointMainnet  = "https://api.kyve.network"
	RestEndpointKaon     = "https://api.kaon.kyve.network"
	RestEndpointKorellia = "https://api.korellia.kyve.network"

	RestEndpointArweave     = "https://arweave.net"
	RestEndpointBundlr      = "https://arweave.net"
	RestEndpointKYVEStorage = "https://storage.kyve.network"
	RestEndpointTurbo       = "https://arweave.net"
)
View Source
const (
	IndexBlockHeight            = 0
	IndexSlotNumber             = 1
	IndexBlobByNamespace        = 2
	IndexSharesByNamespace      = 3
	IndexTendermintBlock        = 4
	IndexTendermintBlockResults = 5
	IndexTendermintBlockByHash  = 6
	IndexAllBlobsByNamespace    = 7
	IndexEVMValue               = 8
	IndexEVMBlock               = 9
	IndexEVMTransaction         = 10
	IndexEVMReceipt             = 11
	IndexEVMLog                 = 12
)
View Source
const (
	BundlesPageLimit  = 100
	BackoffMaxRetries = 10
)
View Source
const (
	DefaultChainId     = ChainIdMainnet
	DefaultRegistryURL = "https://raw.githubusercontent.com/KYVENetwork/source-registry/main/.github/registry.yml"
)

Variables

View Source
var (
	PrometheusSyncStarted         *prometheus.CounterVec
	PrometheusSyncFinished        *prometheus.CounterVec
	PrometheusBundlesSynced       *prometheus.CounterVec
	PrometheusSyncStepFailedRetry *prometheus.CounterVec

	PrometheusProcessDuration *prometheus.GaugeVec
	PrometheusBundleSize      *prometheus.GaugeVec
	PrometheusBundleHeight    *prometheus.GaugeVec
)

Functions

func BytesToHex

func BytesToHex(bytes *[][32]byte) []string

func CalculateSHA256Hash

func CalculateSHA256Hash(obj interface{}) [32]byte

func CreateSha256Checksum

func CreateSha256Checksum(input []byte) (hash string)

func DecodeProof

func DecodeProof(encodedProofString string) (*types.Proof, error)

DecodeProof decodes the proof of a data item from a byte array encodedProofString is the base64 string of the proof see EncodeProof for more information returns the proof as a struct

func DecompressGzip

func DecompressGzip(input []byte) ([]byte, error)

func EncodeProof

func EncodeProof(poolId, bundleId int64, chainId string, dataItemKey, dataItemValueKey string, proof []types.MerkleNode) string

EncodeProof encodes the proof of a data item into a byte array encoded in big endian Structure: - 1 bytes: version (uint8) - 2 bytes: poolId (uint16) - 8 bytes: bundleId (uint64) - chainId (string, null terminated) - dataItemKey (string, null terminated) - dataItemValueKey (string, null terminated) - Array of merkle nodes:

  • 1 byte: left (true/false)
  • 32 bytes: hash (sha256)

returns the proof as Base64

func GetChainRest

func GetChainRest(chainId, chainRest string) string

func GetFromUrl

func GetFromUrl(url string) ([]byte, error)

GetFromUrl tries to fetch data from url with a custom User-Agent header

func GetFromUrlWithBackoff

func GetFromUrlWithBackoff(url string) (data []byte, err error)

GetFromUrlWithBackoff tries to fetch data from url with exponential backoff

func GetUniqueDataitemName

func GetUniqueDataitemName(item *types.TrustlessDataItem) string

func GetVersion

func GetVersion() string

func StartPrometheus

func StartPrometheus(port string)

func TrustlessApiLogger

func TrustlessApiLogger(moduleName string) zerolog.Logger

func WrapIntoJsonRpcErrorResponse

func WrapIntoJsonRpcErrorResponse(errorMessage string, data any) any

func WrapIntoJsonRpcResponse

func WrapIntoJsonRpcResponse(result interface{}) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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