cache

package
v1.5.1-testnet Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CfxDefault = NewCfx()

Functions

func MustInitFromViper

func MustInitFromViper()

Types

type CfxCache

type CfxCache struct {
	*StatusCache
	// contains filtered or unexported fields
}

CfxCache memory cache for some core space RPC methods

func NewCfx

func NewCfx() *CfxCache

func (*CfxCache) GetClientVersion

func (cache *CfxCache) GetClientVersion(cfx sdk.ClientOperator) (string, bool, error)

func (*CfxCache) GetClientVersionWithFunc

func (cache *CfxCache) GetClientVersionWithFunc(rawGetter func() (interface{}, error)) (string, bool, error)

func (*CfxCache) GetGasPrice

func (cache *CfxCache) GetGasPrice(cfx sdk.ClientOperator) (*hexutil.Big, bool, error)

func (*CfxCache) GetGasPriceWithFunc

func (cache *CfxCache) GetGasPriceWithFunc(rawGetter func() (interface{}, error)) (*hexutil.Big, bool, error)

type EthCache

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

EthCache memory cache for some evm space RPC methods

var (
	EthDefault *EthCache = newEthCache(newEthCacheConfig())
)

func (*EthCache) Call

func (cache *EthCache) Call(
	nodeName string,
	client *web3go.Client,
	callRequest types.CallRequest,
	blockNum *types.BlockNumberOrHash,
) (RPCResult, bool, error)

func (*EthCache) CallWithFunc

func (cache *EthCache) CallWithFunc(
	nodeName string,
	rawGetter func() (interface{}, error),
	callRequest types.CallRequest,
	blockNum *types.BlockNumberOrHash,
) (RPCResult, bool, error)

func (*EthCache) GetBlockNumber

func (cache *EthCache) GetBlockNumber(nodeName string, client *web3go.Client) (*hexutil.Big, bool, error)

func (*EthCache) GetBlockNumberWithFunc

func (cache *EthCache) GetBlockNumberWithFunc(nodeName string, rawGetter func() (interface{}, error)) (*hexutil.Big, bool, error)

func (*EthCache) GetChainId

func (cache *EthCache) GetChainId(client *web3go.Client) (*hexutil.Uint64, bool, error)

func (*EthCache) GetChainIdWithFunc

func (cache *EthCache) GetChainIdWithFunc(rawGetter func() (interface{}, error)) (*hexutil.Uint64, bool, error)

func (*EthCache) GetClientVersion

func (cache *EthCache) GetClientVersion(client *web3go.Client) (string, bool, error)

func (*EthCache) GetClientVersionWithFunc

func (cache *EthCache) GetClientVersionWithFunc(rawGetter func() (interface{}, error)) (string, bool, error)

func (*EthCache) GetGasPrice

func (cache *EthCache) GetGasPrice(client *web3go.Client) (*hexutil.Big, bool, error)

func (*EthCache) GetGasPriceWithFunc

func (cache *EthCache) GetGasPriceWithFunc(rawGetter func() (interface{}, error)) (*hexutil.Big, bool, error)

func (*EthCache) GetNetVersion

func (cache *EthCache) GetNetVersion(client *web3go.Client) (string, bool, error)

func (*EthCache) GetNetVersionWithFunc

func (cache *EthCache) GetNetVersionWithFunc(rawGetter func() (interface{}, error)) (string, bool, error)

type EthCacheConfig

type EthCacheConfig struct {
	NetVersionExpiration    time.Duration `default:"1m"`
	ClientVersionExpiration time.Duration `default:"1m"`
	ChainIdExpiration       time.Duration `default:"8760h"`
	BlockNumberExpiration   time.Duration `default:"1s"`
	PriceExpiration         time.Duration `default:"3s"`
	CallCacheExpiration     time.Duration `default:"1s"`
	CallCacheSize           int           `default:"128"`
}

type RPCResult

type RPCResult struct {
	Data     interface{}
	RpcError error
}

RPCResult represents the result of an RPC call, containing the response data or a potential JSON-RPC error.

type StatusCache

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

StatusCache memory cache for core space status related RPC method suites.

func NewStatusCache

func NewStatusCache() *StatusCache

func (*StatusCache) GetBestBlockHash

func (c *StatusCache) GetBestBlockHash(nodeName string, cfx sdk.ClientOperator) (types.Hash, bool, error)

func (*StatusCache) GetBestBlockHashWithFunc

func (c *StatusCache) GetBestBlockHashWithFunc(nodeName string, rawGetter func() (interface{}, error)) (types.Hash, bool, error)

func (*StatusCache) GetEpochNumber

func (c *StatusCache) GetEpochNumber(nodeName string, cfx sdk.ClientOperator, epoch *types.Epoch) (*hexutil.Big, bool, error)

func (*StatusCache) GetEpochNumberWithFunc

func (c *StatusCache) GetEpochNumberWithFunc(
	nodeName string, rawGetter func() (interface{}, error), epoch *types.Epoch) (*hexutil.Big, bool, error)

func (*StatusCache) GetStatus

func (c *StatusCache) GetStatus(nodeName string, cfx sdk.ClientOperator) (types.Status, bool, error)

func (*StatusCache) GetStatusWithFunc

func (c *StatusCache) GetStatusWithFunc(nodeName string, rawGetter func() (interface{}, error)) (types.Status, bool, error)

Jump to

Keyboard shortcuts

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