chain

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGenesisExist        = errors.New("genesis block is existed")
	ErrBuildGenesisFail    = errors.New("build genesis block failed")
	ErrSaveGenesisFail     = errors.New("save genesis block failed")
	ErrGenesisExtraTooLong = errors.New("genesis config's extraData is longer than 256")
	ErrGenesisTimeTooLarge = errors.New("genesis config's time is larger than current time")
	ErrNoDeputyNodes       = errors.New("no deputy nodes in genesis")
	ErrInvalidDeputyNodes  = errors.New("genesis config's deputy nodes are invalid")
)
View Source
var (
	TotalLEMO              = common.Lemo2Mo("1600000000")                                  // 1.6 billion
	DefaultFounder         = mustDecodeAddress("Lemo83RJZ3ATGP2CDQYSRN9AWZQZQ8P24694G5Z3") // Initial LEMO holder
	DefaultDeputyNodesInfo = infos{
		&CandidateInfo{
			MinerAddress:  mustDecodeAddress("Lemo83PT4CRWS4QQ3KQN5HSQ9KY9C2ZAYWGANZY8"),
			IncomeAddress: mustDecodeAddress("Lemo83R9DWRRD9HDW8HATA9R558ANQ93R4AQBFHQ"),
			NodeID:        common.FromHex("0xa496266523fbdc3541d238fbc161ac4aad2b9939c01553e5ec6969581dfe33946703c720cf09870b0f90b13894153a363a17634d78303d28639f63d8c0182e92"),
			Host:          "127.0.0.1",
			Port:          "7001",
			Introduction:  "LemoChain Node 1",
		},
		&CandidateInfo{
			MinerAddress:  mustDecodeAddress("Lemo848R4PKJ8CZ2TBQC58K92Z2S3N23SNSNAQ8K"),
			IncomeAddress: mustDecodeAddress("Lemo835SBHCBGGTKR6GY67GNZ6KG9BB85QNTZ5CP"),
			NodeID:        common.FromHex("0xfc5bd09388220b8c9887edb58f30aee2dfc1cbfddb2842e20b3417332518862f03a37e4d93378c2171f263d007038b9c550dbe06f5b5557a47757ee96cc0e7da"),
			Host:          "127.0.0.1",
			Port:          "7002",
			Introduction:  "LemoChain Node 2",
		},
		&CandidateInfo{
			MinerAddress:  mustDecodeAddress("Lemo848RTFC7D55284Z6RYSBRYNQ7968SSZ74269"),
			IncomeAddress: mustDecodeAddress("Lemo837F67QG2AC472SRW4PD8RWDB5SQ4H6K9HQP"),
			NodeID:        common.FromHex("0xc2061403840154c5adfa3aba18a51b246964078ff055dc745bdb77f97fa0a97ee453a13e313ca20ec9bec37bde590e96d1fd29dd49b65e159ddcfcc5771d3077"),
			Host:          "127.0.0.1",
			Port:          "7003",
			Introduction:  "LemoChain Node 3",
		},
		&CandidateInfo{
			MinerAddress:  mustDecodeAddress("Lemo832363YDBAAKZKTKKA24HTZ99288487RF3QG"),
			IncomeAddress: mustDecodeAddress("Lemo83FW5J9DJ9PTNTFGS9F5FW554QKFFBRNP573"),
			NodeID:        common.FromHex("0xe9e437bd288d0984197cb8b7c9a6a7e28467613d182c5bad734953516c8e8775119a3eb86eb6bc3a25f0c5c93723553cbdd7909de0108952f17e4fe72af7b05b"),
			Host:          "127.0.0.1",
			Port:          "7004",
			Introduction:  "LemoChain Node 4",
		},
		&CandidateInfo{
			MinerAddress:  mustDecodeAddress("Lemo837PN8C5JB9GG4CYZR3KHDPCDWNY2FWT7KKD"),
			IncomeAddress: mustDecodeAddress("Lemo83QJCRRWR4J75ANNWNSGZFJBS5DW3AGG4NSG"),
			NodeID:        common.FromHex("0xa974b10a4ca92e50db6ba2578abe3979787315f081ae3e2b4fbbd93cca45efae75b33ad079d4dea20dd4557b3d746a7f04bfcb362f0347ece7c9677d01e220fe"),
			Host:          "127.0.0.1",
			Port:          "7005",
			Introduction:  "LemoChain Node 5",
		},
		&CandidateInfo{
			MinerAddress:  mustDecodeAddress("Lemo83QP4RJWR7QCTPRAQ824897A8BJ5DJDGZD2T"),
			IncomeAddress: mustDecodeAddress("Lemo83QQGTDAYN4SW462WTBKTKBHSDKW96D2W848"),
			NodeID:        common.FromHex("0xeebeeb9528bc8d172dcf47076eae31da5989ec81eb528cafc566fed593d4a09c20198dc51eecc3b2634ba374d98e0e4bf4d9d2b3c11d5e99b6641745e5e23a9a"),
			Host:          "127.0.0.1",
			Port:          "7006",
			Introduction:  "LemoChain Node 6",
		},
	}
)
View Source
var ErrLoadBlock = errors.New("load block fail")
View Source
var ErrNoGenesis = errors.New("can't get genesis block")

Functions

func SetupGenesisBlock

func SetupGenesisBlock(db protocol.ChainDB, genesis *Genesis) *types.Block

SetupGenesisBlock setup genesis block

Types

type BlockChain

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

func NewBlockChain

func NewBlockChain(config Config, dm *deputynode.Manager, db db.ChainDB, flags flag.CmdFlags, txPool *txpool.TxPool) (bc *BlockChain, err error)

func (*BlockChain) AccountManager

func (bc *BlockChain) AccountManager() *account.Manager

func (*BlockChain) ChainID

func (bc *BlockChain) ChainID() uint16

ChainID

func (*BlockChain) CurrentBlock

func (bc *BlockChain) CurrentBlock() *types.Block

CurrentBlock get latest current block

func (*BlockChain) DeputyManager added in v1.2.0

func (bc *BlockChain) DeputyManager() *deputynode.Manager

func (*BlockChain) FetchConfirm added in v1.4.0

func (bc *BlockChain) FetchConfirm(height uint32) error

func (*BlockChain) Flags

func (bc *BlockChain) Flags() flag.CmdFlags

func (*BlockChain) Founder added in v1.2.0

func (bc *BlockChain) Founder() common.Address

Founder is LEMO holder in the genesis block

func (*BlockChain) Genesis

func (bc *BlockChain) Genesis() *types.Block

Genesis genesis block

func (*BlockChain) GetBlockByHash

func (bc *BlockChain) GetBlockByHash(hash common.Hash) *types.Block

func (*BlockChain) GetBlockByHeight

func (bc *BlockChain) GetBlockByHeight(height uint32) *types.Block

func (*BlockChain) GetCandidatesTop added in v1.3.0

func (bc *BlockChain) GetCandidatesTop(hash common.Hash) []*store.Candidate

func (*BlockChain) GetParentByHeight added in v1.3.0

func (bc *BlockChain) GetParentByHeight(height uint32, sonBlockHash common.Hash) *types.Block

func (*BlockChain) HasBlock

func (bc *BlockChain) HasBlock(hash common.Hash) bool

HasBlock has special block in local

func (*BlockChain) InsertBlock added in v1.3.0

func (bc *BlockChain) InsertBlock(block *types.Block) error

InsertBlock insert block of non-self to chain

func (*BlockChain) InsertConfirms added in v1.4.0

func (bc *BlockChain) InsertConfirms(height uint32, blockHash common.Hash, sigList []types.SignData)

InsertConfirms receive confirm package from net connection

func (*BlockChain) IsInBlackList added in v1.3.0

func (bc *BlockChain) IsInBlackList(b *types.Block) bool

func (*BlockChain) LogForks added in v1.4.0

func (bc *BlockChain) LogForks()

LogForks print the forks graph

func (*BlockChain) MineBlock added in v1.3.0

func (bc *BlockChain) MineBlock(txProcessTimeout int64)

func (*BlockChain) StableBlock

func (bc *BlockChain) StableBlock() *types.Block

StableBlock get latest stable block

func (*BlockChain) Stop

func (bc *BlockChain) Stop()

Stop stop block chain

func (*BlockChain) TxGuard added in v1.4.0

func (bc *BlockChain) TxGuard() *txpool.TxGuard

func (*BlockChain) TxProcessor

func (bc *BlockChain) TxProcessor() *transaction.TxProcessor

type CandidateInfo added in v1.4.0

type CandidateInfo struct {
	MinerAddress  common.Address `json:"minerAddress" gencodec:"required"`
	IncomeAddress common.Address `json:"incomeAddress" gencodec:"required"`
	NodeID        []byte         `json:"nodeID" gencodec:"required"`
	Host          string         `json:"host" gencodec:"required"`
	Port          string         `json:"port" gencodec:"required"`
	Introduction  string         `json:"introduction"`
}

func (CandidateInfo) MarshalJSON added in v1.4.0

func (c CandidateInfo) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*CandidateInfo) UnmarshalJSON added in v1.4.0

func (c *CandidateInfo) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Config added in v1.3.0

type Config struct {
	ChainID     uint16
	MineTimeout uint64 // milliseconds
}

Config holds chain options.

type Genesis

type Genesis struct {
	Time            uint32           `json:"timestamp"`
	ExtraData       string           `json:"extraData"`
	GasLimit        uint64           `json:"gasLimit"`
	Founder         common.Address   `json:"founder"       gencodec:"required"`
	DeputyNodesInfo []*CandidateInfo `json:"deputyNodesInfo"   gencodec:"required"`
}

func DefaultGenesisConfig added in v1.4.0

func DefaultGenesisConfig() *Genesis

DefaultGenesisConfig default genesis block config

func (Genesis) MarshalJSON

func (g Genesis) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Genesis) ToBlock

func (g *Genesis) ToBlock(am *account.Manager) (*types.Block, error)

ToBlock

func (*Genesis) UnmarshalJSON

func (g *Genesis) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

func (*Genesis) Verify added in v1.4.0

func (g *Genesis) Verify() error

Directories

Path Synopsis
vm
abi
Package abi implements the Lemochain ABI (Application Binary Interface).
Package abi implements the Lemochain ABI (Application Binary Interface).
runtime
Package runtime provides a basic execution model for executing EVM code.
Package runtime provides a basic execution model for executing EVM code.

Jump to

Keyboard shortcuts

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