chains

package
v1.0.4-update-id-2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: BSD-3-Clause Imports: 32 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainParameters

type ChainParameters struct {
	ID          ids.ID   // The ID of the chain being created
	SubnetID    ids.ID   // ID of the subnet that validates this chain
	GenesisData []byte   // The genesis data of this chain's ledger
	VMAlias     string   // The ID of the vm this chain is running
	FxAliases   []string // The IDs of the feature extensions this chain is running

	CustomBeacons validators.Set // Should only be set if the default beacons can't be used.
}

ChainParameters defines the chain being created

type Manager

type Manager interface {
	// Return the router this Manager is using to route consensus messages to chains
	Router() router.Router

	// Create a chain in the future
	CreateChain(ChainParameters)

	// Create a chain now
	ForceCreateChain(ChainParameters)

	// Add a registrant [r]. Every time a chain is
	// created, [r].RegisterChain([new chain]) is called
	AddRegistrant(Registrant)

	// Given an alias, return the ID of the chain associated with that alias
	Lookup(string) (ids.ID, error)

	// Given an alias, return the ID of the VM associated with that alias
	LookupVM(string) (ids.ID, error)

	// Return the aliases associated with a chain
	Aliases(ids.ID) []string

	// Add an alias to a chain
	Alias(ids.ID, string) error

	// Returns the ID of the subnet that is validating the provided chain
	SubnetID(chainID ids.ID) (ids.ID, error)

	// Returns true iff the chain with the given ID exists and is finished bootstrapping
	IsBootstrapped(ids.ID) bool

	Shutdown()
}

Manager manages the chains running on this node. It can:

  • Create a chain
  • Add a registrant. When a chain is created, each registrant calls RegisterChain with the new chain as the argument.
  • Get the aliases associated with a given chain.
  • Get the ID of the chain associated with a given alias.

func New

func New(config *ManagerConfig) Manager

New returns a new Manager where:

<db> is this node's database
<sender> sends messages to other validators
<validators> validate this chain

TODO: Make this function take less arguments

type ManagerConfig added in v0.8.0

type ManagerConfig struct {
	StakingEnabled          bool // True iff the network has staking enabled
	MaxNonStakerPendingMsgs uint32
	StakerMSGPortion        float64
	StakerCPUPortion        float64
	Log                     logging.Logger
	LogFactory              logging.Factory
	VMManager               vms.Manager // Manage mappings from vm ID --> vm
	DecisionEvents          *triggers.EventDispatcher
	ConsensusEvents         *triggers.EventDispatcher
	DB                      database.Database
	Router                  router.Router      // Routes incoming messages to the appropriate chain
	Net                     network.Network    // Sends consensus messages to other validators
	ConsensusParams         avcon.Parameters   // The consensus parameters (alpha, beta, etc.) for new chains
	Validators              validators.Manager // Validators validating on this chain
	NodeID                  ids.ShortID        // The ID of this node
	NetworkID               uint32             // ID of the network this node is connected to
	Server                  *api.Server        // Handles HTTP API calls
	Keystore                *keystore.Keystore
	AtomicMemory            *atomic.Memory
	AVAXAssetID             ids.ID
	XChainID                ids.ID
	CriticalChains          ids.Set          // Chains that can't exit gracefully
	WhitelistedSubnets      ids.Set          // Subnets to validate
	TimeoutManager          *timeout.Manager // Manages request timeouts when sending messages to other validators
	HealthService           *health.Health
}

ManagerConfig ...

type MockManager

type MockManager struct{}

MockManager implements Manager but does nothing. Always returns nil error. To be used only in tests

func (MockManager) AddRegistrant

func (mm MockManager) AddRegistrant(Registrant)

AddRegistrant ...

func (MockManager) Alias

func (mm MockManager) Alias(ids.ID, string) error

Alias ...

func (MockManager) Aliases

func (mm MockManager) Aliases(ids.ID) []string

Aliases ...

func (MockManager) CreateChain

func (mm MockManager) CreateChain(ChainParameters)

CreateChain ...

func (MockManager) ForceCreateChain

func (mm MockManager) ForceCreateChain(ChainParameters)

ForceCreateChain ...

func (MockManager) IsBootstrapped added in v0.8.0

func (mm MockManager) IsBootstrapped(ids.ID) bool

IsBootstrapped ...

func (MockManager) Lookup

func (mm MockManager) Lookup(s string) (ids.ID, error)

Lookup ...

func (MockManager) LookupVM

func (mm MockManager) LookupVM(s string) (ids.ID, error)

LookupVM ...

func (MockManager) Router

func (mm MockManager) Router() router.Router

Router ...

func (MockManager) Shutdown

func (mm MockManager) Shutdown()

Shutdown ...

func (MockManager) SubnetID added in v0.8.0

func (mm MockManager) SubnetID(ids.ID) (ids.ID, error)

SubnetID ...

type Registrant

type Registrant interface {
	RegisterChain(ctx *snow.Context, vm interface{})
}

Registrant can register the existence of a chain

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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