dipperin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: LGPL-3.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir is the default data directory to use for the databases and other persistence requirements.

func DefaultMinerP2PConf

func DefaultMinerP2PConf() p2p.Config

func DefaultP2PConf

func DefaultP2PConf() p2p.Config

get the default p2p configuration

Types

type BaseComponent

type BaseComponent struct {
	DipperinConfig *service.DipperinConfig
	// contains filtered or unexported fields
}

type BlockValidator

type BlockValidator interface {
	Valid(block model.AbstractBlock) error
	FullValid(block model.AbstractBlock) error
}

type Chain

type Chain interface {
	InsertBlocks(blocks []model.AbstractBlock) error

	Genesis() model.AbstractBlock

	CurrentBlock() model.AbstractBlock
	CurrentHeader() model.AbstractHeader

	CurrentSeed() (common.Hash, uint64)
	IsChangePoint(block model.AbstractBlock, isProcessPackageBlock bool) bool
	GetLastChangePoint(block model.AbstractBlock) *uint64
	GetSlotByNum(num uint64) *uint64
	GetSlot(block model.AbstractBlock) *uint64

	GetCurrVerifiers() []common.Address
	GetVerifiers(round uint64) []common.Address
	GetNextVerifiers() []common.Address

	GetBlock(hash common.Hash, number uint64) model.AbstractBlock
	GetBlockByHash(hash common.Hash) model.AbstractBlock
	GetBlockByNumber(number uint64) model.AbstractBlock
	GetLatestNormalBlock() model.AbstractBlock

	HasBlock(hash common.Hash, number uint64) bool

	GetBody(hash common.Hash) model.AbstractBody
	GetBodyRLP(hash common.Hash) rlp.RawValue

	GetHeader(hash common.Hash, number uint64) model.AbstractHeader
	GetHeaderByHash(hash common.Hash) model.AbstractHeader
	GetHeaderByNumber(number uint64) model.AbstractHeader
	GetHeaderRLP(hash common.Hash) rlp.RawValue
	HasHeader(hash common.Hash, number uint64) bool

	GetBlockNumber(hash common.Hash) *uint64
	GetTransaction(txHash common.Hash) (model.AbstractTransaction, common.Hash, uint64, uint64)

	GetStateStorage() state_processor.StateStorage
	CurrentState() (*state_processor.AccountStateDB, error)
	StateAtByBlockNumber(num uint64) (*state_processor.AccountStateDB, error)
	StateAtByStateRoot(root common.Hash) (*state_processor.AccountStateDB, error)

	ValidTx(tx model.AbstractTransaction) error

	GetSeenCommit(height uint64) []model.AbstractVerification
	SaveBlock(block model.AbstractBlock, seenCommits []model.AbstractVerification) error
}

fixme use cs_chain

type ChainVerifiersReader

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

func MakeVerifiersReader

func MakeVerifiersReader(fullChain cs_chain.Chain) *ChainVerifiersReader

TODO: change back to the permission

func (*ChainVerifiersReader) CurrentVerifiers

func (verifier *ChainVerifiersReader) CurrentVerifiers() []common.Address

func (*ChainVerifiersReader) GetPBFTPrimaryNode

func (verifier *ChainVerifiersReader) GetPBFTPrimaryNode() common.Address

fetch the primary node that have proposed the current block. But if it's the last block of the current round, then it should return the primary node of the next round.

func (*ChainVerifiersReader) NextVerifiers

func (verifier *ChainVerifiersReader) NextVerifiers() []common.Address

func (*ChainVerifiersReader) PrimaryNode

func (verifier *ChainVerifiersReader) PrimaryNode() common.Address

fetch the primary node that have proposed the current block

func (*ChainVerifiersReader) ShouldChangeVerifier

func (verifier *ChainVerifiersReader) ShouldChangeVerifier() bool

func (*ChainVerifiersReader) VerifiersTotalCount

func (verifier *ChainVerifiersReader) VerifiersTotalCount() int

type CsNode

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

func NewCsNode

func NewCsNode(services []NodeService) *CsNode

func (*CsNode) AddService

func (n *CsNode) AddService(service NodeService)

func (*CsNode) Start

func (n *CsNode) Start() (err error)

func (*CsNode) Stop

func (n *CsNode) Stop()

func (*CsNode) Wait

func (n *CsNode) Wait()

type ExtraServiceFunc

type ExtraServiceFunc func(c ExtraServiceFuncConfig) (apis []rpc.API, services []NodeService)

type ExtraServiceFuncConfig

type ExtraServiceFuncConfig struct {
	service.DipperinConfig

	ChainService *service.MercuryFullChainService
}

type MsgSender

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

func (*MsgSender) BroadcastEiBlock

func (m *MsgSender) BroadcastEiBlock(block model.AbstractBlock)

func (*MsgSender) BroadcastMsg

func (m *MsgSender) BroadcastMsg(msgCode uint64, msg interface{})

func (*MsgSender) SendReqRoundMsg

func (m *MsgSender) SendReqRoundMsg(msgCode uint64, from []common.Address, msg interface{})

type Node

type Node interface {
	// add extra service before node start
	AddService(service NodeService)
	Start() error
	Stop()
	Wait()
}

manage dipperin app lifetime

func NewBftNode

func NewBftNode(nodeConfig NodeConfig) (n Node)

func NewMinerNode

func NewMinerNode(master string, coinbase string, minerCount int, p2pListenAddr string) (n Node, err error)

type NodeConfig

type NodeConfig struct {
	// cur node name
	Name string

	P2PListener string

	IPCPath string
	// app data dir
	DataDir string
	// HTTPHost is the host interface on which to start the HTTP RPC server. If this
	// field is empty, no HTTP API endpoint will be started.
	HTTPHost string `toml:",omitempty"`

	// HTTPPort is the TCP port number on which to start the HTTP RPC server. The
	// default zero value is/ valid and will pick a port number randomly (useful
	// for ephemeral nodes).
	HTTPPort int `toml:",omitempty"`
	// WSHost is the host interface on which to start the websocket RPC server. If
	// this field is empty, no websocket API endpoint will be started.
	WSHost string `toml:",omitempty"`

	// WSPort is the TCP port number on which to start the websocket RPC server. The
	// default zero value is/ valid and will pick a port number randomly (useful for
	// ephemeral nodes).
	WSPort int `toml:",omitempty"`

	// 0 normal 1 mine master 2 verifier
	NodeType int

	// Set debug mode, 0 is single node not broadcast, 1 is multi-node with PBFT, 2 is multi-node with PBFT and election
	DebugMode int

	SoftWalletPassword   string
	SoftWalletPassPhrase string
	SoftWalletPath       string
	IsStartMine          bool

	//used to set the default account of pbft
	DefaultAccountKey string

	// Whether it includes browser function. 0 is not, 1 is
	IsScanner int

	IsUploadNodeData int

	//whether tps monitoring function 0 is not 1 is
	IsPerformance int
	// example http://127.0.0.1:8080
	UploadURL string

	NoDiscovery int
	Nat         string

	AllowHosts []string

	PMetricsPort int

	ExtraServiceFunc ExtraServiceFunc
}

start a dipperin node config node config only in here, other module should use interface to use this config

func DefaultNodeConf

func DefaultNodeConf() NodeConfig

get the default node config

func (NodeConfig) FullChainDBDir

func (conf NodeConfig) FullChainDBDir() string

full and fast use same dir, fast to full should start sync history states

func (NodeConfig) GetAllowHosts

func (conf NodeConfig) GetAllowHosts() []string

func (NodeConfig) GetIsStartMine

func (conf NodeConfig) GetIsStartMine() bool

func (NodeConfig) GetIsUploadNodeData

func (conf NodeConfig) GetIsUploadNodeData() int

func (NodeConfig) GetNodeHTTPPort

func (conf NodeConfig) GetNodeHTTPPort() string

func (NodeConfig) GetNodeName

func (conf NodeConfig) GetNodeName() string

func (NodeConfig) GetNodeP2PPort

func (conf NodeConfig) GetNodeP2PPort() string

func (NodeConfig) GetNodeType

func (conf NodeConfig) GetNodeType() int

func (NodeConfig) GetPMetricsPort

func (conf NodeConfig) GetPMetricsPort() int

func (NodeConfig) GetUploadURL

func (conf NodeConfig) GetUploadURL() string

func (NodeConfig) HttpEndpoint

func (conf NodeConfig) HttpEndpoint() string

func (NodeConfig) IpcEndpoint

func (conf NodeConfig) IpcEndpoint() string

func (NodeConfig) LightChainDBDir

func (conf NodeConfig) LightChainDBDir() string

func (NodeConfig) SoftWalletDir

func (conf NodeConfig) SoftWalletDir() string

func (NodeConfig) SoftWalletFile

func (conf NodeConfig) SoftWalletFile() string

func (NodeConfig) SoftWalletName

func (conf NodeConfig) SoftWalletName() string

func (NodeConfig) WsEndpoint

func (conf NodeConfig) WsEndpoint() string

type NodeService

type NodeService interface {
	Start() error
	Stop()
}

type VerifiersReader

type VerifiersReader interface {
	CurrentVerifiers() []common.Address
	NextVerifiers() []common.Address
	PrimaryNode() common.Address
	GetPBFTPrimaryNode() common.Address
	VerifiersTotalCount() int
	ShouldChangeVerifier() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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