container

package
v0.0.0-...-f798b02 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: LGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FirstOctet  = 172
	SecondOctet = 17
)

Variables

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

Functions

func GetGoSmiloImage

func GetGoSmiloImage() string

func GetSpeaker

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

func GetVaultImage

func GetVaultImage() string

func NewBlockchain

func NewBlockchain(network *DockerNetwork, numOfFullnodes int, options ...Option) (bc *blockchain, err error)

func NewDefaultBlockchain

func NewDefaultBlockchain(network *DockerNetwork, numOfFullnodes int) (bc *blockchain, err error)

func NewDefaultBlockchainWithFaulty

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

func NewDefaultSmiloBlockchain

func NewDefaultSmiloBlockchain(network *DockerNetwork, ctn VaultNetwork) (bc *blockchain, err error)

func NewDefaultSmiloBlockchainWithFaulty

func NewDefaultSmiloBlockchainWithFaulty(network *DockerNetwork, ctn VaultNetwork, numOfNormal int, numOfFaulty int) (bc *blockchain, err error)

func NewDefaultVaultNetwork

func NewDefaultVaultNetwork(network *DockerNetwork, numOfFullnodes int) (ctn *vaultNetwork, err error)

func NewEthereum

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

func NewSmiloBlockchain

func NewSmiloBlockchain(network *DockerNetwork, ctn VaultNetwork, options ...Option) (bc *blockchain, err error)

func NewVault

func NewVault(c *client.Client, options ...VaultOption) *vault

func NewVaultNetwork

func NewVaultNetwork(network *DockerNetwork, numOfFullnodes int, options ...VaultOption) (ctn *vaultNetwork, err error)

Types

type Blockchain

type Blockchain interface {
	AddFullnodes(numOfFullnodes int) ([]Ethereum, error)
	RemoveFullnodes(candidates []Ethereum, t time.Duration) error
	EnsureConsensusWorking(geths []Ethereum, t time.Duration) error
	Start(bool) error
	Stop(bool) error
	Fullnodes() []Ethereum
	Finalize()
}

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 IsSmilo

func IsSmilo(isSmilo 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 RPCOrigin

func RPCOrigin(origins string) Option

func RPCPort

func RPCPort(port int) Option

func SyncMode

func SyncMode(mode string) Option

func Testnet

func Testnet() 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

type Vault

type Vault interface {
	// GenerateKey() generates private/public key pair
	GenerateKey() (string, error)
	// Start() starts vault service
	Start() error
	// Stop() stops vault service
	Stop() error
	// Host() returns vault 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
}

*

  • Vault interface and constructors *

type VaultNetwork

type VaultNetwork interface {
	Start() error
	Stop() error
	Finalize()
	NumOfVaults() int
	GetVault(int) Vault
}

Vault functions ----------------------------------------------------------------------------

type VaultOption

type VaultOption func(*vault)

TODO: refactor this with ethereum options? *

  • Vault options *

func CTDockerNetworkName

func CTDockerNetworkName(dockerNetworkName string) VaultOption

func CTHost

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

func CTImageRepository

func CTImageRepository(repository string) VaultOption

func CTImageTag

func CTImageTag(tag string) VaultOption

func CTKeyName

func CTKeyName(keyName string) VaultOption

func CTLogging

func CTLogging(enabled bool) VaultOption

func CTOtherNodes

func CTOtherNodes(urls []string) VaultOption

func CTSocketFilename

func CTSocketFilename(socketFilename string) VaultOption

func CTWorkDir

func CTWorkDir(workDir string) VaultOption

Jump to

Keyboard shortcuts

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