proxy

package
v0.19.7-rc0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrNoData

func ErrNoData() error

func GetCertifiedCommit

func GetCertifiedCommit(h int64, node rpcclient.Client, cert lite.Certifier) (lite.Commit, error)

GetCertifiedCommit gets the signed header for a given height and certifies it. Returns error if unable to get a proven header.

func GetCertifier added in v0.14.0

func GetCertifier(chainID, rootDir, nodeAddr string) (*lite.InquiringCertifier, error)

func IsNoDataErr added in v0.14.0

func IsNoDataErr(err error) bool

IsNoDataErr checks whether an error is due to a query returning empty data

func RPCRoutes

func RPCRoutes(c rpcclient.Client) map[string]*rpc.RPCFunc

RPCRoutes just routes everything to the given client, as if it were a tendermint fullnode.

if we want security, the client must implement it as a secure client

func StartProxy

func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger) error

StartProxy will start the websocket manager on the client, set up the rpc routes to proxy via the given client, and start up an http/rpc server on the location given by bind (eg. :1234)

func ValidateBlock

func ValidateBlock(meta *types.Block, check lite.Commit) error

func ValidateBlockMeta

func ValidateBlockMeta(meta *types.BlockMeta, check lite.Commit) error

func ValidateHeader

func ValidateHeader(head *types.Header, check lite.Commit) error

Types

type KeyProof added in v0.16.0

type KeyProof interface {
	// Verify verfies the proof is valid. To verify absence,
	// the value should be nil.
	Verify(key, value, root []byte) error

	// Root returns the root hash of the proof.
	Root() []byte

	// Serialize itself
	Bytes() []byte
}

KeyProof represents a proof of existence or absence of a single key. Copied from iavl repo. TODO

func GetWithProof

func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client,
	cert lite.Certifier) (
	val cmn.HexBytes, height int64, proof KeyProof, err error)

GetWithProof will query the key on the given node, and verify it has a valid proof, as defined by the certifier.

If there is any error in checking, returns an error. If val is non-empty, proof should be KeyExistsProof If val is empty, proof should be KeyMissingProof

func GetWithProofOptions

func GetWithProofOptions(path string, key []byte, opts rpcclient.ABCIQueryOptions,
	node rpcclient.Client, cert lite.Certifier) (
	*ctypes.ResultABCIQuery, KeyProof, error)

GetWithProofOptions is useful if you want full access to the ABCIQueryOptions

type Wrapper

type Wrapper struct {
	rpcclient.Client
	// contains filtered or unexported fields
}

Wrapper wraps a rpcclient with a Certifier and double-checks any input that is provable before passing it along. Allows you to make any rpcclient fully secure.

func SecureClient

func SecureClient(c rpcclient.Client, cert *lite.InquiringCertifier) Wrapper

SecureClient uses a given certifier to wrap an connection to an untrusted host and return a cryptographically secure rpc client.

If it is wrapping an HTTP rpcclient, it will also wrap the websocket interface

func (Wrapper) ABCIQuery

func (w Wrapper) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)

ABCIQuery uses default options for the ABCI query and verifies the returned proof

func (Wrapper) ABCIQueryWithOptions

func (w Wrapper) ABCIQueryWithOptions(path string, data cmn.HexBytes,
	opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

ABCIQueryWithOptions exposes all options for the ABCI query and verifies the returned proof

func (Wrapper) Block

func (w Wrapper) Block(height *int64) (*ctypes.ResultBlock, error)

Block returns an entire block and verifies all signatures

func (Wrapper) BlockchainInfo

func (w Wrapper) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)

BlockchainInfo requests a list of headers and verifies them all... Rather expensive.

TODO: optimize this if used for anything needing performance

func (Wrapper) Commit

func (w Wrapper) Commit(height *int64) (*ctypes.ResultCommit, error)

Commit downloads the Commit and certifies it with the lite.

This is the foundation for all other verification in this module

func (Wrapper) Tx

func (w Wrapper) Tx(hash []byte, prove bool) (*ctypes.ResultTx, error)

Tx queries for a given tx and verifies the proof if it was requested

Jump to

Keyboard shortcuts

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