core

package
v0.0.0-...-45b6777 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const CacheSize = 2000

Variables

View Source
var AllUpstreamsFailedError = fmt.Errorf("all upstream requests are failed")
View Source
var DecodeError = fmt.Errorf("decode error")
View Source
var DeniedContract = fmt.Errorf("not allowed contract or address")
View Source
var DeniedMethod = fmt.Errorf("not allowed method")
View Source
var TimeoutError = fmt.Errorf("timeout error")

Functions

func Count

func Count(key string)

func Handler

func Handler() http.Handler

func LoadConfig

func LoadConfig(ctx context.Context, quit chan bool)

func StartMonitorHttpServer

func StartMonitorHttpServer(ctx context.Context)

func Time

func Time(key string, value float64)

func Value

func Value(key string, value float64)

Types

type BlockNumberResponseData

type BlockNumberResponseData struct {
	JsonRpc string `json:"jsonrpc"`
	ID      int64  `json:"id"`
	Result  string `json:"result"`
}

type ChainConfig

type ChainConfig struct {
	Upstreams               []string `json:"upstreams"`
	OldTrieUrl              string   `json:"oldTrieUrl"`
	Strategy                string   `json:"strategy"`
	MethodLimitationEnabled bool     `json:"methodLimitationEnabled"`
	AllowedMethods          []string `json:"allowedMethods"`
	ContractWhitelist       []string `json:"contractWhitelist"`
}

type Config

type Config map[uint64]ChainConfig

func NewConfig

func NewConfig() *Config

type FallbackProxy

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

type FallbackStatus

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

type HealthInfo

type HealthInfo map[uint64][]NodeInfo

type HttpUpstream

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

type IStrategy

type IStrategy interface {
	// contains filtered or unexported methods
}

type JsonRpcError

type JsonRpcError struct {
	Code    int64  `json:"code"`
	Message string `json:"message"`
}

type JsonRpcResponse

type JsonRpcResponse struct {
	JsonRpc string       `json:"jsonrpc"`
	ID      int64        `json:"id"`
	Err     JsonRpcError `json:"error"`
	Result  interface{}  `json:"result"`
}

type LoadBalanceFallbackProxy

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

type NaiveProxy

type NaiveProxy struct{}

type NodeInfo

type NodeInfo struct {
	RpcUrl  string `json:"rpcUrl"` // only first 20 chars
	Latency string `json:"latency"`
	Height  uint64 `json:"height"`
	IsAlive bool   `json:"isAlive"`
}

type RaceProxy

type RaceProxy struct{}

type ReqCacheKey

type ReqCacheKey struct {
	ChainId uint64 `json:"chainId"`
	RequestData
}

type Request

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

type RequestData

type RequestData struct {
	JsonRpc string        `json:"jsonrpc"`
	ID      int64         `json:"id,omitempty"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
}

type RunningChainConfig

type RunningChainConfig struct {
	Upstreams               []Upstream
	Strategy                IStrategy
	MethodLimitationEnabled bool
	// contains filtered or unexported fields
}

type RunningConfig

type RunningConfig struct {
	Configs map[uint64]*RunningChainConfig
	// contains filtered or unexported fields
}

func BuildRunningConfigFromConfig

func BuildRunningConfigFromConfig(parentContext context.Context, cfg *Config) (*RunningConfig, error)

func NewRunningConfig

func NewRunningConfig(ctx context.Context, cfg *Config) (*RunningConfig, error)

type Server

type Server struct{}

func (*Server) ServeHTTP

func (h *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

Support path: 1. /ws/{chainId} 2. /http/{chainId}

func (*Server) ServerWS

func (h *Server) ServerWS(chainId uint64, conn *websocket.Conn) error

type Upstream

type Upstream interface {
	// contains filtered or unexported methods
}

the handle function will execute concurrently

type WsUpstream

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

Jump to

Keyboard shortcuts

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