container

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: LGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FirstOctet  = 172
	SecondOctet = 17
)
View Source
const (
	ArbitraryNetworkId = "2018"
)

Variables

View Source
var (
	ErrNoBlock = errors.New("no block generated")
	ErrTimeout = errors.New("timeout")
)

Functions

func GetProposer

func GetProposer(header *types.Header) common.Address

func NewBlockchain

func NewBlockchain(network *DockerNetwork, numOfValidators int, options ...Option) (bc *blockchain)

func NewConstellation

func NewConstellation(c *client.Client, options ...ConstellationOption) *constellation

func NewConstellationNetwork

func NewConstellationNetwork(network *DockerNetwork, numOfValidators int, options ...ConstellationOption) (ctn *constellationNetwork)

func NewDefaultBlockchain

func NewDefaultBlockchain(network *DockerNetwork, numOfValidators int) (bc *blockchain)

func NewDefaultBlockchainWithFaulty

func NewDefaultBlockchainWithFaulty(network *DockerNetwork, numOfNormal int, numOfFaulty int) (bc *blockchain)

func NewDefaultConstellationNetwork

func NewDefaultConstellationNetwork(network *DockerNetwork, numOfValidators int) (ctn *constellationNetwork)

func NewDefaultQuorumBlockchain

func NewDefaultQuorumBlockchain(network *DockerNetwork, ctn ConstellationNetwork) (bc *blockchain)

func NewDefaultQuorumBlockchainWithFaulty

func NewDefaultQuorumBlockchainWithFaulty(network *DockerNetwork, ctn ConstellationNetwork, numOfNormal int, numOfFaulty int) (bc *blockchain)

func NewEthereum

func NewEthereum(c *docker.Client, options ...Option) *ethereum

func NewQuorumBlockchain

func NewQuorumBlockchain(network *DockerNetwork, ctn ConstellationNetwork, options ...Option) (bc *blockchain)

Types

type Blockchain

type Blockchain interface {
	AddValidators(numOfValidators int) ([]Ethereum, error)
	RemoveValidators(candidates []Ethereum, t time.Duration) error
	EnsureConsensusWorking(geths []Ethereum, t time.Duration) error
	Start(bool) error
	Stop(bool) error
	Validators() []Ethereum
	Finalize()
}

type Constellation

type Constellation interface {
	// GenerateKey() generates private/public key pair
	GenerateKey() (string, error)
	// Start() starts constellation service
	Start() error
	// Stop() stops constellation service
	Stop() error
	// Host() returns constellation service url
	Host() string
	// Running() returns true if container is running
	Running() bool
	// WorkDir() returns local working directory
	WorkDir() string
	// ConfigPath() returns container config path
	ConfigPath() string
	// Binds() returns volume binding paths
	Binds() []string
	// PublicKeys() return public keys
	PublicKeys() []string
}

*

  • Constellation interface and constructors *

type ConstellationNetwork

type ConstellationNetwork interface {
	Start() error
	Stop() error
	Finalize()
	NumOfConstellations() int
	GetConstellation(int) Constellation
}

Constellation functions ----------------------------------------------------------------------------

type ConstellationOption

type ConstellationOption func(*constellation)

TODO: refactor this with ethereum options? *

  • Constellation options *

func CTDockerNetworkName

func CTDockerNetworkName(dockerNetworkName string) ConstellationOption

func CTHost

func CTHost(ip net.IP, port int) ConstellationOption

func CTImageRepository

func CTImageRepository(repository string) ConstellationOption

func CTImageTag

func CTImageTag(tag string) ConstellationOption

func CTKeyName

func CTKeyName(keyName string) ConstellationOption

func CTLogging

func CTLogging(enabled bool) ConstellationOption

func CTOtherNodes

func CTOtherNodes(urls []string) ConstellationOption

func CTSocketFilename

func CTSocketFilename(socketFilename string) ConstellationOption

func CTVerbosity

func CTVerbosity(verbosity int) ConstellationOption

func CTWorkDir

func CTWorkDir(workDir string) ConstellationOption

type DockerNetwork

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

func NewDockerNetwork

func NewDockerNetwork() (*DockerNetwork, error)

func (*DockerNetwork) GetFreeIPAddrs

func (n *DockerNetwork) GetFreeIPAddrs(num int) ([]net.IP, error)

func (*DockerNetwork) ID

func (n *DockerNetwork) ID() string

func (*DockerNetwork) Name

func (n *DockerNetwork) Name() string

func (*DockerNetwork) Remove

func (n *DockerNetwork) Remove() error

func (*DockerNetwork) Subnet

func (n *DockerNetwork) Subnet() string

type Ethereum

type Ethereum interface {
	Init(string) error
	Start() error
	Stop() error

	NodeAddress() string
	Address() common.Address

	ContainerID() string
	Host() string
	NewClient() client.Client
	ConsensusMonitor(err chan<- error, quit chan struct{})

	WaitForProposed(expectedAddress common.Address, t time.Duration) error
	WaitForPeersConnected(int) error
	WaitForBlocks(int, ...time.Duration) error
	WaitForBlockHeight(int) error
	// Want for block for no more than the given number during the given time duration
	WaitForNoBlocks(int, time.Duration) error

	// Wait for settling balances for the given accounts
	WaitForBalances([]common.Address, ...time.Duration) error

	AddPeer(string) error

	StartMining() error
	StopMining() error

	Accounts() []common.Address

	DockerEnv() []string
	DockerBinds() []string
}

type NetworkManager

type NetworkManager interface {
	TryGetFreeSubnet() string
}

type NodeIncubator

type NodeIncubator interface {
	CreateNodes(int, ...Option) ([]Ethereum, error)
}

type Option

type Option func(*ethereum)

func Accounts

func Accounts(accounts []common.Address) Option

func DataDir

func DataDir(dir string) Option

func DockerBinds

func DockerBinds(binds []string) Option

func DockerEnv

func DockerEnv(env []string) Option

func DockerNetworkName

func DockerNetworkName(dockerNetworkName string) Option

func Etherbase

func Etherbase(etherbase string) Option

func FaultyMode

func FaultyMode(mode int) Option

func HostDataDir

func HostDataDir(path string) Option

func HostIP

func HostIP(ip net.IP) Option

func HostName

func HostName(hostName string) Option

func HostPort

func HostPort(port int) Option

func HostRPCPort

func HostRPCPort(port int) Option

func HostWebSocketPort

func HostWebSocketPort(port int) Option

func IPC

func IPC(enabled bool) Option

func Identity

func Identity(id string) Option

func ImageRepository

func ImageRepository(repository string) Option

func ImageTag

func ImageTag(tag string) Option

func IsQuorum

func IsQuorum(isQuorum bool) Option

func Key

func Key(key *ecdsa.PrivateKey) Option

func KeyStore

func KeyStore(dir string) Option

func Logging

func Logging(enabled bool) Option

func Mine

func Mine() Option

func NAT

func NAT(nat string) Option

func NetworkID

func NetworkID(networkID string) Option

func NoDiscover

func NoDiscover() Option

func NoUSB

func NoUSB() Option

func NodeKey

func NodeKey(nodekey string) Option

func NodeKeyHex

func NodeKeyHex(hex string) Option

func Password

func Password(password string) Option

func Port

func Port(port int) Option

func RPC

func RPC() Option

func RPCAPI

func RPCAPI(apis string) Option

func RPCAddress

func RPCAddress(address string) Option

func RPCPort

func RPCPort(port int) Option

func SyncMode

func SyncMode(mode string) Option

func Unlock

func Unlock(index int) Option

func Verbosity

func Verbosity(verbosity int) Option

func WebSocket

func WebSocket() Option

func WebSocketAPI

func WebSocketAPI(apis string) Option

func WebSocketAddress

func WebSocketAddress(address string) Option

func WebSocketOrigin

func WebSocketOrigin(origins string) Option

func WebSocketPort

func WebSocketPort(port int) Option

Jump to

Keyboard shortcuts

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