cache

package
v0.23.6 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagLogLevel       = "log_level"
	FlagMetricsAddress = "metrics_address"
)
View Source
const (
	ExpirationFlagName               = "expiration"
	ExpirationNonFinalizedFlagName   = "expiration-non-finalized"
	DefaultExpirationForNonFinalized = 500 * time.Millisecond
	DefaultExpirationTimeFinalized   = time.Hour
	CacheMaxCost                     = 2 * 1024 * 1024 * 1024 // 2GB cost
	CacheNumCounters                 = 100000000              // expect 10M items
)
View Source
const (
	DisabledFlagOption = "disabled"
)
View Source
const (
	SEP = ";"
)

Variables

View Source
var (
	NotFoundError     = sdkerrors.New("Cache miss", 1, "cache entry for specific block and request wasn't found")                                                   // client could'nt connect to any provider.
	HashMismatchError = sdkerrors.New("Cache hit but hash mismatch", 2, "cache entry for specific block and request had a mismatching hash stored")                 // client could'nt connect to any provider.
	EntryTypeError    = sdkerrors.New("Cache hit but entry is a different object", 3, "cache entry for specific block and request had a mismatching object stored") // client could'nt connect to any provider.
)

Functions

func CreateCacheCobraCommand

func CreateCacheCobraCommand() *cobra.Command

func Server

func Server(
	ctx context.Context,
	listenAddr string,
	metricsAddr string,
	flags *pflag.FlagSet,
)

Types

type CacheMetrics

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

func NewCacheMetricsServer

func NewCacheMetricsServer(listenAddress string) *CacheMetrics

func (*CacheMetrics) AddApiSpecific

func (c *CacheMetrics) AddApiSpecific(block int64, chainId string, method string, apiInterface string, hit bool)

type CacheServer

type CacheServer struct {
	ExpirationFinalized    time.Duration
	ExpirationNonFinalized time.Duration
	CacheMetrics           *CacheMetrics
	// contains filtered or unexported fields
}

func (*CacheServer) ExpirationForChain

func (cs *CacheServer) ExpirationForChain(chainID string) time.Duration

func (*CacheServer) InitCache

func (cs *CacheServer) InitCache(ctx context.Context, expiration time.Duration, expirationNonFinalized time.Duration, metricsAddr string)

func (*CacheServer) Serve

func (cs *CacheServer) Serve(ctx context.Context,
	listenAddr string,
)

type CacheValue

type CacheValue struct {
	Response         pairingtypes.RelayReply
	Hash             []byte
	OptionalMetadata []pairingtypes.Metadata
}

func (*CacheValue) Cost

func (cv *CacheValue) Cost() int64

func (*CacheValue) ToCacheReply

func (cv *CacheValue) ToCacheReply() *pairingtypes.CacheRelayReply

type LastestCacheStore

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

func (*LastestCacheStore) Cost

func (cv *LastestCacheStore) Cost() int64

type RelayerCacheServer

type RelayerCacheServer struct {
	pairingtypes.UnimplementedRelayerCacheServer
	CacheServer *CacheServer
	// contains filtered or unexported fields
}

func (*RelayerCacheServer) GetRelay

func (s *RelayerCacheServer) GetRelay(ctx context.Context, relayCacheGet *pairingtypes.RelayCacheGet) (cacheReply *pairingtypes.CacheRelayReply, err error)

func (*RelayerCacheServer) Health

func (*RelayerCacheServer) PrintCacheStats

func (s *RelayerCacheServer) PrintCacheStats(ctx context.Context, desc string)

func (*RelayerCacheServer) SetRelay

func (s *RelayerCacheServer) SetRelay(ctx context.Context, relayCacheSet *pairingtypes.RelayCacheSet) (*emptypb.Empty, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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