client

package
v0.0.0-...-f39f649 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	UNKNOWN   = "😕 Unknown"
	TRUSTED   = "😀 Benevolent"
	UNTRUSTED = "😠 Malicious"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceReport

type BalanceReport struct {
	Balance *big.Int
}

BalanceReport will be displayed by the GUI.

type Client

type Client struct {
	psync.Closer
	// Initialized in NewClient
	Config   config.ClientConfig
	OpConfig config.OpClientConfig
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg config.ClientConfig, ccfg config.OpClientConfig, conn *RPC, events chan *Event, ethClient *eth.Client, signer tee.TextSigner) *Client

func (*Client) ActiveBlock

func (c *Client) ActiveBlock() uint64

func (*Client) Address

func (c *Client) Address() common.Address

func (*Client) BalanceProofWatcher

func (c *Client) BalanceProofWatcher()

BalanceProofWatcher waits for the balance proof of an epoch and disputes if non was received after the TxPhase + balanceProofGrace. Can currently only deal with one deposit per deposit-phase. Should be started in a go-routine.

func (*Client) ChainURL

func (c *Client) ChainURL() string

ChainURL returns the URL of the blockchain the client is connected to.

func (*Client) CmdBench

func (c *Client) CmdBench(status chan *CmdStatus, args ...string)

func (*Client) CmdChallenge

func (c *Client) CmdChallenge(status chan *CmdStatus, args ...string)

func (*Client) CmdDeposit

func (c *Client) CmdDeposit(status chan *CmdStatus, args ...string)

func (*Client) CmdLeave

func (c *Client) CmdLeave(status chan *CmdStatus, args ...string)

func (*Client) CmdSend

func (c *Client) CmdSend(status chan *CmdStatus, args ...string)

func (*Client) LastBlock

func (c *Client) LastBlock() uint64

func (*Client) Run

func (c *Client) Run() error

type CmdStatus

type CmdStatus struct {
	Msg string
	Err error
	War string // Warning
}

type EpochBalance

type EpochBalance struct {
	tee.Balance
	Dep *tee.DepositProof
	Bal *tee.BalanceProof
}

EpochBalance describes the balance that a specific user has/has in a epoch. Currently, onls only one deposit per Epoch is allowed otherwise it would need a slice of `*DepositProof`s. The Proofs are initialized to nil, the DepositProof should be set after the Deposit succeeded. The BalanceProof should be set at the end of a Transaction phase.

func (*EpochBalance) Clone

func (e *EpochBalance) Clone() *EpochBalance

type Event

type Event struct {
	Type          EventType
	Params        tee.Parameters // SET_PARAMS
	Report        BalanceReport  // SET_BALANCE
	OpTrust       Trust
	Result        Result
	Message       string        // CHAIN_MSG
	BlockNum      uint64        // NEW_BLOCK
	EpochNum      uint64        // NEW_EPOCH
	ExitAvailable *EpochBalance // SET_EXIT_AVAIL
}

type EventType

type EventType = int
const (
	SET_PARAMS EventType = iota
	SET_BALANCE
	SET_OP_TRUST   // Emitted when operator becomes malicious
	SET_EXIT_AVAIL // Emitted when an exit becomes (in)available

	NEW_BLOCK // New block mined
	NEW_EPOCH
	CHAIN_MSG // Chain related message.

	BENCH
)

type RPC

type RPC struct {
	pkgsync.Closer
	// contains filtered or unexported fields
}

RPC connects the client with the operator over websockets.

func NewRPC

func NewRPC(host string, port uint16) (*RPC, error)

NewRPC returns a new RPC object. RPC immediately tries to connect to the operator and starts to handle incomming data. You may want to call Subscribe afterwards if you need balance and/or deposit proofs.

func (*RPC) ClientCfg

func (r *RPC) ClientCfg() config.OpClientConfig

ClientCfg returns the operator's client config.

func (*RPC) Log

func (r *RPC) Log() *log.Entry

func (*RPC) SendTx

func (r *RPC) SendTx(ctx context.Context, tx tee.Transaction) error

SendTx sends one transaction to the operator.

func (*RPC) Subscribe

func (r *RPC) Subscribe(ctx context.Context, user common.Address) (*Subscription, error)

Subscribe subscribes to the Balance and Deposit proof topic. The user must always read the proofs via `DepositProof` and `BalanceProof`. Calling this function more than once if it did not error will cause undefined behaviour.

type Result

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

func Benchmark

func Benchmark(n int, f func() error) (r Result, e error)

func (Result) String

func (r Result) String() string

type Subscription

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

Subscription is returned by Subscribe() and can be used to iterate over the deposit and balance proofs.

func (*Subscription) BalanceProof

func (s *Subscription) BalanceProof(ctx context.Context) (tee.BalanceProof, error)

BalanceProof blocks until it can return the next balance proof from the operator.

func (*Subscription) DepositProof

func (s *Subscription) DepositProof(ctx context.Context) (tee.DepositProof, error)

DepositProof blocks until it can return the next deposit proof from the operator.

func (*Subscription) Log

func (r *Subscription) Log() *log.Entry

func (*Subscription) TxReceipt

func (s *Subscription) TxReceipt(ctx context.Context) (tee.Transaction, error)

TxReceipt blocks until it can return the next pending incoming transaction from the operator.

type Trust

type Trust = string

Trust describes how we perceive the operator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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