local

package
v1.2.0-rc Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockCounter

func BlockCounter() (chain.BlockCounter, error)

BlockCounter creates a BlockCounter that runs completely locally. It is designed to simply increase block height at a set time interval in the background.

Types

type Chain

type Chain interface {
	chain.Handle

	// GetLastDKGResult returns the last DKG result submitted to the chain
	// as well as all the signatures that supported that result.
	GetLastDKGResult() (*relaychain.DKGResult, map[relaychain.GroupMemberIndex][]byte)

	// GetLastRelayEntry returns the last relay entry submitted to the chain.
	GetLastRelayEntry() []byte

	// GetRelayEntryTimeoutReports returns an array of blocks which denote at what
	// block a relay entry timeout occured.
	GetRelayEntryTimeoutReports() []uint64
}

Chain is an extention of chain.Handle interface which exposes additional functions useful for testing.

func Connect

func Connect(
	groupSize int,
	honestThreshold int,
	minimumStake *big.Int,
) Chain

Connect initializes a local stub implementation of the chain interfaces for testing. It uses auto-generated operator key.

func ConnectWithKey

func ConnectWithKey(
	groupSize int,
	honestThreshold int,
	minimumStake *big.Int,
	operatorKey *ecdsa.PrivateKey,
) Chain

ConnectWithKey initializes a local stub implementation of the chain interfaces for testing.

type StakeMonitor

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

StakeMonitor implements `chain.StakeMonitor` interface and works as a local stub for testing.

func NewStakeMonitor

func NewStakeMonitor(minimumStake *big.Int) *StakeMonitor

NewStakeMonitor creates a new instance of `StakeMonitor` test stub.

func (*StakeMonitor) HasMinimumStake

func (lsm *StakeMonitor) HasMinimumStake(address string) (bool, error)

HasMinimumStake checks if the provided address staked enough to become a network operator. The minimum stake is an on-chain parameter.

func (*StakeMonitor) StakeTokens

func (lsm *StakeMonitor) StakeTokens(address string) error

StakeTokens stakes enough tokens for the provided address to be a network operator. It stakes `5 * minimumStake` by default.

func (*StakeMonitor) StakerFor

func (lsm *StakeMonitor) StakerFor(address string) (chain.Staker, error)

StakerFor returns a staker.Staker instance for the given address. Returns an error if the address is invalid.

func (*StakeMonitor) UnstakeTokens

func (lsm *StakeMonitor) UnstakeTokens(address string) error

UnstakeTokens unstakes all tokens from the provided address so it can no longer be a network operator.

Jump to

Keyboard shortcuts

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