proxy

package
v0.0.0-...-168a2c3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App interface {
	// CommitHandler is called when Lachesis commits a block to the DAG. It returns
	// the state hash resulting from applying the block's transactions to the state.
	CommitHandler(block poset.Block) (stateHash []byte, err error)

	// SnapshotHandler is called by Lachesis to retrieve a snapshot
	// corresponding to a particular block.
	SnapshotHandler(blockIndex int64) (snapshot []byte, err error)

	// RestoreHandler is called by Lachesis to restore the application
	// to a specific state.
	RestoreHandler(snapshot []byte) (stateHash []byte, err error)
}

App provides an interface for the application to set handlers for committing, retrieving and restoring state and transactions.

type AppProxy

type AppProxy interface {
	// SubmitCh returns the channel of app transactions.
	SubmitCh() chan []byte
	// SubmitInternalCh returns the channel of stake transactions.
	SubmitInternalCh() chan inter.InternalTransaction
	CommitBlock(block poset.Block) ([]byte, error)
	GetSnapshot(blockIndex int64) ([]byte, error)
	Restore(snapshot []byte) error
	Close()
}

AppProxy is an interface for lachesis to communicate with the application.

func NewGrpcAppProxy

func NewGrpcAppProxy(bind string, timeout time.Duration, logger *logrus.Logger, listen network.ListenFunc) (
	res AppProxy, addr string, err error)

NewGrpcAppProxy instantiates a joined AppProxy-interface listen to remote apps.

func NewInmemAppProxy

func NewInmemAppProxy(handler App, logger *logrus.Logger) AppProxy

NewInmemAppProxy instantiates an InmemProxy from a set of handlers.

type Consensus

type Consensus interface {
	StakeOf(peer hash.Peer) uint64
	GetTransaction(hash.Transaction) *inter.InternalTransaction
}

Consensus is a set of consensus handlers.

type CtrlProxy

type CtrlProxy interface {
	// Set ...
	Set()
	// Close stops proxy.
	Close()
}

CtrlProxy is a control proxy.

func NewGrpcCtrlProxy

func NewGrpcCtrlProxy(bind string, n Node, c Consensus, logger *logrus.Logger, listen network.ListenFunc) (
	res CtrlProxy, addr string, err error)

NewGrpcCtrlProxy starts Ctrl proxy.

type LachesisProxy

type LachesisProxy interface {
	CommitCh() chan proto.Commit
	SnapshotRequestCh() chan proto.SnapshotRequest
	RestoreCh() chan proto.RestoreRequest
	SubmitTx(tx []byte) error
	Close()
}

LachesisProxy is an interface for application to communicate with the lachesis.

func NewGrpcLachesisProxy

func NewGrpcLachesisProxy(addr string, logger *logrus.Logger, opts ...grpc.DialOption) (LachesisProxy, error)

NewGrpcLachesisProxy initiates a LachesisProxy-interface connected to remote lachesis node.

type Node

type Node interface {
	GetID() hash.Peer
	AddInternalTxn(inter.InternalTransaction) (hash.Transaction, error)
}

Node is a set of node handlers.

type NodeProxy

type NodeProxy interface {
	// GetSelfID returns node id.
	GetSelfID() (hash.Peer, error)
	// StakeOf returns stake balance of peer.
	StakeOf(hash.Peer) (uint64, error)
	// SendTo makes stake transfer transaction.
	SendTo(receiver hash.Peer, index, amount, until uint64) (hash.Transaction, error)
	// GetTransaction returns information about transaction.
	GetTransaction(hash.Transaction) (*inter.InternalTransaction, error)
	// SetLogLevel sets logger log level.
	SetLogLevel(string) error
	// Close stops proxy.
	Close()
}

NodeProxy is an interface for remote node controlling.

func NewGrpcNodeProxy

func NewGrpcNodeProxy(addr string, logger *logrus.Logger, opts ...grpc.DialOption) (NodeProxy, error)

NewGrpcNodeProxy initiates a NodeProxy-interface connected to remote node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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