verifiers_halt_check

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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenVoteMsg

func GenVoteMsg(emptyBlock *model.Block, signFunc SignHashFunc, addr common.Address, voteType model.VoteMsgType) (*model.VoteMsg, error)

Types

type AliveVerHaltHandler

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

alive verifier halt handler

func NewAliveVerHaltHandler

func NewAliveVerHaltHandler(signFunc SignHashFunc, addr common.Address) *AliveVerHaltHandler

func (*AliveVerHaltHandler) OnMinimalHashBlock

func (handler *AliveVerHaltHandler) OnMinimalHashBlock(selectedProposal ProposalMsg) (*model.VoteMsg, error)

type CsProtocolFunction

type CsProtocolFunction interface {
	GetVerifierBootNode() map[string]chain_communication.PmAbstractPeer
	GetNextVerifierPeers() map[string]chain_communication.PmAbstractPeer
	GetCurrentVerifierPeers() map[string]chain_communication.PmAbstractPeer
}

type HaltCheckConf

type HaltCheckConf struct {
	NodeType        int
	CsProtocol      CsProtocolFunction
	NeedChainReader NeedChainReaderFunction
	WalletSigner    NeedWalletSigner
	Broadcast       broadcastEmptyBlock
	EconomyModel    economy_model.EconomyModel
}

type NeedChainReaderFunction

type NeedChainReaderFunction interface {
	CurrentBlock() model.AbstractBlock
	GetSeenCommit(height uint64) []model.AbstractVerification
	GetCurrVerifiers() []common.Address
	SaveBlock(block model.AbstractBlock, seenCommits []model.AbstractVerification) error

	//AccountDB need ChainReader function
	GetBlockByNumber(number uint64) model.AbstractBlock
	GetVerifiers(round uint64) []common.Address

	IsChangePoint(block model.AbstractBlock, isProcessPackageBlock bool) bool
	GetLastChangePoint(block model.AbstractBlock) *uint64
	GetSlot(block model.AbstractBlock) *uint64

	BlockProcessor(root common.Hash) (*chain.BlockProcessor, error)
	BlockProcessorByNumber(num uint64) (*chain.BlockProcessor, error)

	BuildRegisterProcessor(preRoot common.Hash) (*registerdb.RegisterDB, error)
}

type NeedWalletSigner

type NeedWalletSigner interface {
	GetAddress() common.Address
	SignHash(hash []byte) ([]byte, error)
	PublicKey() *ecdsa.PublicKey
	ValidSign(hash []byte, pubKey []byte, sign []byte) error
	Evaluate(account accounts.Account, seed []byte) (index [32]byte, proof []byte, err error)
}

type ProcessFunc

type ProcessFunc func(block model.AbstractBlock, preStateRoot, preRegisterRoot common.Hash) (stateRoot, registerRoot common.Hash, err error)

type ProposalGenerator

type ProposalGenerator struct {
	ProposalGeneratorConfig
	// contains filtered or unexported fields
}

func (*ProposalGenerator) GenEmptyBlock

func (g *ProposalGenerator) GenEmptyBlock() (*model.Block, error)

func (*ProposalGenerator) GenProposal

func (g *ProposalGenerator) GenProposal() (*ProposalMsg, error)

type ProposalGeneratorConfig

type ProposalGeneratorConfig struct {
	// block need
	CurBlock          model.AbstractBlock
	NewBlockSeed      common.Hash
	NewBlockProof     []byte
	LastVerifications []model.AbstractVerification
	PubKey            []byte

	// vote msg need
	SignHashFunc SignHashFunc

	//process account and register need
	ProcessStateFunc ProcessFunc

	VoteType model.VoteMsgType
}

type ProposalMsg

type ProposalMsg struct {
	Round      uint64
	EmptyBlock model.Block
	VoteMsg    model.VoteMsg
}

func GenProposalMsg

func GenProposalMsg(config ProposalGeneratorConfig) (*ProposalMsg, error)

generate ProposalMsg

type SignHashFunc

type SignHashFunc func(hash []byte) ([]byte, error)

type StateHandler

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

func MakeHaltCheckStateHandler

func MakeHaltCheckStateHandler(needChainReader NeedChainReaderFunction, walletSigner NeedWalletSigner, economyModel economy_model.EconomyModel) *StateHandler

func (*StateHandler) GenProposalConfig

func (haltCheckStateHandle *StateHandler) GenProposalConfig(voteType model.VoteMsgType) (ProposalGeneratorConfig, error)

func (*StateHandler) ProcessAccountAndRegisterState

func (haltCheckStateHandle *StateHandler) ProcessAccountAndRegisterState(block model.AbstractBlock, preStateRoot, preRegisterRoot common.Hash) (stateRoot, registerRoot common.Hash, err error)

func (*StateHandler) SaveFinalEmptyBlock

func (haltCheckStateHandle *StateHandler) SaveFinalEmptyBlock(proposal ProposalMsg, votes map[common.Address]model.VoteMsg) error

type SystemHaltedCheck

type SystemHaltedCheck struct {
	//verifier boot node synchronization status
	SynStatus uint32
	// contains filtered or unexported fields
}

func MakeSystemHaltedCheck

func MakeSystemHaltedCheck(conf *HaltCheckConf) *SystemHaltedCheck

func (*SystemHaltedCheck) MsgHandlers

func (systemHaltedCheck *SystemHaltedCheck) MsgHandlers() map[uint64]func(msg p2p.Msg, p chain_communication.PmAbstractPeer) error

func (*SystemHaltedCheck) Start

func (systemHaltedCheck *SystemHaltedCheck) Start() error

func (*SystemHaltedCheck) Stop

func (systemHaltedCheck *SystemHaltedCheck) Stop()

type VBHaltHandler

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

verifier boot node halt handler A new one is generated after each timeout. This way resetting the state is not needed after finishing processing.

func NewHaltHandler

func NewHaltHandler(conf ProposalGeneratorConfig) *VBHaltHandler

func (*VBHaltHandler) GetMinProposalMsg

func (handler *VBHaltHandler) GetMinProposalMsg() ProposalMsg

func (*VBHaltHandler) GetOtherProposalMessages

func (handler *VBHaltHandler) GetOtherProposalMessages() []ProposalMsg

func (*VBHaltHandler) GetProposalMsg

func (handler *VBHaltHandler) GetProposalMsg() *ProposalMsg

func (*VBHaltHandler) HandlerAliveVerVotes

func (handler *VBHaltHandler) HandlerAliveVerVotes(vote model.VoteMsg, currentVerifiers []common.Address) error

func (*VBHaltHandler) HandlerProposalMessages

func (handler *VBHaltHandler) HandlerProposalMessages(msg ProposalMsg, selectedProposal chan ProposalMsg) error

handle the received proposals and change the haltHandler status

func (*VBHaltHandler) MinProposalMsg

func (handler *VBHaltHandler) MinProposalMsg() ProposalMsg

func (*VBHaltHandler) OnNewProposalMsg

func (handler *VBHaltHandler) OnNewProposalMsg(msg ProposalMsg) error

receive msg of other VBoot

func (*VBHaltHandler) ProposeEmptyBlock

func (handler *VBHaltHandler) ProposeEmptyBlock() (pm ProposalMsg, err error)

generate proposalMsg

func (*VBHaltHandler) VotesLen

func (handler *VBHaltHandler) VotesLen() int

Jump to

Keyboard shortcuts

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