proxynode

package
v0.0.0-...-f5bbbf4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package mock is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ProxyHandler = jsonrpc.DefaultRWHandler(
	jsonrpc.HandlerFunc(func(rw jsonrpc.ResponseWriter, msg *jsonrpc.RequestMsg) {

		resp, err := SessionFromContext(msg.Context()).ClientRPC().Do(msg)
		if err != nil {
			_ = jsonrpc.WriteError(rw, err)
		} else {
			_ = rw.WriteMsg(resp)
		}
	}),
)

Functions

func WithSession

func WithSession(ctx context.Context, n Session) context.Context

Types

type Config

type Config struct {
	RPC           *DownstreamConfig `json:"rpc,omitempty" yaml:"rpc,omitempty"`
	PrivTxManager *DownstreamConfig `json:"tessera,omitempty" yaml:"tessera,omitempty"`
}

Config is the cfg format for a Hashicorp Vault secret store

func (*Config) SetDefault

func (cfg *Config) SetDefault() *Config

type DownstreamConfig

type DownstreamConfig struct {
	Addr          string            `json:"addr" yaml:"addr" validate:"required" example:"http://geth:8545"`
	Transport     *transport.Config `json:"transport,omitempty" yaml:"transport,omitempty"`
	Proxy         *ProxyConfig      `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	ClientTimeout *json.Duration    `json:"clientTimeout,omitempty" yaml:"client_timeout,omitempty"`
}

func (*DownstreamConfig) SetDefault

func (cfg *DownstreamConfig) SetDefault() *DownstreamConfig

type MockSession

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

MockSession is a mock of Session interface.

func NewMockSession

func NewMockSession(ctrl *gomock.Controller) *MockSession

NewMockSession creates a new mock instance.

func (*MockSession) ClientPrivTxManager

func (m *MockSession) ClientPrivTxManager() tessera.Client

ClientPrivTxManager mock base method.

func (*MockSession) ClientRPC

func (m *MockSession) ClientRPC() jsonrpc.Client

ClientRPC mock base method.

func (*MockSession) EXPECT

func (m *MockSession) EXPECT() *MockSessionMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSession) EthCaller

func (m *MockSession) EthCaller() ethereum.Caller

EthCaller mock base method.

type MockSessionMockRecorder

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

MockSessionMockRecorder is the mock recorder for MockSession.

func (*MockSessionMockRecorder) ClientPrivTxManager

func (mr *MockSessionMockRecorder) ClientPrivTxManager() *gomock.Call

ClientPrivTxManager indicates an expected call of ClientPrivTxManager.

func (*MockSessionMockRecorder) ClientRPC

func (mr *MockSessionMockRecorder) ClientRPC() *gomock.Call

ClientRPC indicates an expected call of ClientRPC.

func (*MockSessionMockRecorder) EthCaller

func (mr *MockSessionMockRecorder) EthCaller() *gomock.Call

EthCaller indicates an expected call of EthCaller.

type Node

type Node struct {
	// Handler is the JSON-RPC handler
	Handler jsonrpc.Handler
	// contains filtered or unexported fields
}

Node is a node connected to JSON-RPC downstream and a Tessera downstream allowing to intercept proxy JSON-RPC

func New

func New(cfg *Config, logger log.Logger) (*Node, error)

New creates a Node

func (*Node) ServeHTTP

func (n *Node) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*Node) Start

func (n *Node) Start(ctx context.Context) error

func (*Node) Stop

func (n *Node) Stop(ctx context.Context) error

type ProxyConfig

type ProxyConfig struct {
	Request   *request.ProxyConfig   `json:"request,omitempty" yaml:"request,omitempty"`
	Response  *response.ProxyConfig  `json:"response,omitempty" yaml:"response,omitempty"`
	WebSocket *websocket.ProxyConfig `json:"websocket,omitempty" yaml:"websocket,omitempty"`
}

func (*ProxyConfig) SetDefault

func (cfg *ProxyConfig) SetDefault() *ProxyConfig

type Session

type Session interface {
	// ClientRPC returns a client to downstream JSON-RPC
	ClientRPC() jsonrpc.Client

	// EthCaller returns a caller to downstream Ethereum JSON-RPC
	EthCaller() ethereum.Caller

	// ClientPrivTxManager returns client to downstream private transaction manager
	ClientPrivTxManager() tessera.Client
}

Session holds client interface to a downstream node

func SessionFromContext

func SessionFromContext(ctx context.Context) Session

Jump to

Keyboard shortcuts

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