ethproxy

package
v0.0.0-...-9331011 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShallCache

func ShallCache(blockID BlockID) bool

ShallCache tells whether a block with a given ID shall be cached or not

Types

type BlockCache

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

BlockCache stores blocks in a map ordered by BlockID in the LRU-style

func NewBlockCache

func NewBlockCache(capacity uint32) *BlockCache

NewBlockCache creates and initializes a new cache with a given capacity

func (*BlockCache) Get

func (cache *BlockCache) Get(blockID BlockID) (string, error)

Get returns cached block or an error otherwise

func (*BlockCache) PutOrUpdate

func (cache *BlockCache) PutOrUpdate(blockID BlockID, block string)

PutOrUpdate caches a block or just updates its lastUsed property

type BlockID

type BlockID string

BlockID is either a natural number or a string like "latest"

type ProxyServer

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

ProxyServer fetches and caches Ethereum blocks

func NewProxyServer

func NewProxyServer(gatewayURL string, blockCache *BlockCache) *ProxyServer

NewProxyServer creates and initializes a new proxy server using provided gateway URL and block cache

func (*ProxyServer) ServeHTTP

func (ps *ProxyServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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