chain

package
v0.0.0-...-6fdbc3c Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Chains denotes all valid chains
	Chains = map[string]*Config{
		"eth": {
			ID:   Ethereum,
			Name: "mainnet",
			Type: EVM,
			Test: false,
		},

		"ropsten": {
			ID:   Ropsten,
			Name: "ropsten",
			Type: EVM,
			Test: true,
		},

		"rinkeby": {
			ID:   Rinkeby,
			Name: "rinkeby",
			Type: EVM,
			Test: true,
		},

		"kovan": {
			ID:   Kovan,
			Name: "kovan",
			Type: EVM,
			Test: true,
		},

		"localhost": {
			ID:   LocalHost,
			Name: "localhost",
			Type: EVM,
			Test: true,
		},
	}
)
View Source
var (
	// ErrChain is thrown on an unsupported chain
	ErrChain = errors.New("invalid chain")
)

Functions

This section is empty.

Types

type Chain

type Chain interface {
	// Open the chain
	Open() error

	// Close the chain
	Close() error

	// Run the on chain protocol
	Run(chan node.Peer) error

	// Join the provider network
	Join([]byte, []byte) error

	// Peers queries the provider network for a list of peers
	Peers() ([]node.Peer, error)
}

Chain defines the interface for a generic chain

func New

func New(cfg *Config, uri string) (Chain, error)

New returns a new chain corresponding to a chain config

type Config

type Config struct {
	ID   ID     // chain id
	Name string // canonical name
	Type Type   // underlying runtime
	Test bool   // true if testnet
}

Config represents a set of chain parameters

type ID

type ID uint64

ID is a chain's unique identifier

const (
	// Ethereum mainnet
	Ethereum ID = 1

	// Ropsten testnet
	Ropsten ID = 3

	// Rinkeby testnet
	Rinkeby ID = 4

	// Kovan testnet
	Kovan ID = 42

	// LocalHost network
	LocalHost ID = 1337
)

type Type

type Type uint64

Type denotes a family of chains

const (
	// EVM compatible chains
	EVM Type = 1
)

func (Type) String

func (t Type) String() (s string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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