nodeHbft

package
v0.0.0-...-e1f35ab Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: LGPL-3.0 Imports: 14 Imported by: 5

Documentation

Index

Constants

View Source
const (
	BlockSealingBeat = time.Millisecond * 100

	BlockMinPeriodHbft     = time.Second * 2
	BlockMaxPeriodHbft     = time.Second * 6
	BlockMaxStartDelayHbft = (BlockMaxPeriodHbft - BlockMinPeriodHbft) / 2
	BlockAvgPeriodHbft     = BlockMaxPeriodHbft + BlockMinPeriodHbft - BlockMaxStartDelayHbft - BlockMinPeriodHbft/2

	NodeServerMinCountHbft = 4
)

Variables

This section is empty.

Functions

func Error

func Error(msg string, ctx ...interface{})

func HBFTDebugInfo

func HBFTDebugInfo(msg string)

func Info

func Info(msg string, ctx ...interface{})

func LogStage

func LogStage(info string, isDone bool)

func LogStageReset

func LogStageReset()

func Trace

func Trace(msg string, ctx ...interface{})

func Warn

func Warn(msg string, ctx ...interface{})

Types

type Elephant

type Elephant interface {
	Etherbase() (eb common.Address, err error)
	AccountManager() *accounts.Manager
	SendBFTMsg(msg interface{}, msgType uint)
	GetCurRealSealers() ([]common.Address, bool)
	GetRealSealersByNum(number uint64) ([]common.Address, bool)
	Get2fRealSealersCnt() int
	GetCurrentBlock() *types.Block
	AddBFTFutureBlock(b *types.Block)
	BFTFutureBlocks() []*types.Block
	BFTOldestFutureBlock() *types.Block
	NextIsNewSealersFirstBlock(block *types.Block) bool
	ValidateNewBftBlocks(blocks []*types.Block) error
	SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
}

type Node

type Node struct {
	//NodeID       string
	NodeTable    map[common.Address]int64 // stores the validators and the time that the node should start to seal a new block
	CurrentState *hbft.State
	CoinBase     common.Address

	ReceivedBlocks []*types.Block    // block buffer that store the blocks we received.
	ReplyBuffer    *[]*hbft.ReplyMsg // stores the replies of pre-confirm or confirm messages

	MsgMutex      sync.Mutex
	ReplyBufMutex sync.Mutex
	SuccMutex     sync.Mutex

	Sealed map[common.Hash]bool

	Lamp       *eth.Ethereum
	EleBackend Elephant
	AccMan     *accounts.Manager
	// contains filtered or unexported fields
}

func NewNode

func NewNode(lamp *eth.Ethereum, elephant Elephant) (*Node, error)

func (*Node) AddReplyMsg

func (node *Node) AddReplyMsg(replyMsg *hbft.ReplyMsg)

func (*Node) BlockSealedCompleted

func (node *Node) BlockSealedCompleted(blockHash common.Hash) bool

func (*Node) GetConfirmMsg

func (node *Node) GetConfirmMsg() (*hbft.ConfirmMsg, error)

func (*Node) GetCurrentSealer

func (node *Node) GetCurrentSealer(sealers []common.Address, selfWork bool) common.Address

func (*Node) GetCurrentStateStage

func (node *Node) GetCurrentStateStage() uint

func (*Node) GetFakeStagesForTest

func (node *Node) GetFakeStagesForTest(viewID uint64) []*types.HBFTStageCompleted

func (*Node) GetReplyMsg

func (node *Node) GetReplyMsg(msg hbft.MsgHbftConsensus) (*hbft.ReplyMsg, error)

func (*Node) GetRequest

func (node *Node) GetRequest(sealerAddr string, block *types.Block)

func (*Node) GetSealedBlockStages

func (node *Node) GetSealedBlockStages() ([]*types.HBFTStageCompleted, bool)

func (*Node) HandleConfirmMsg

func (node *Node) HandleConfirmMsg(confirmMsg *hbft.ConfirmMsg) (*hbft.ReplyMsg, error)

HandleConfirmMsg can be called when the node receives a confirm message.

func (*Node) HandlePreConfirmMsg

func (node *Node) HandlePreConfirmMsg(preConfirmMsg *hbft.PreConfirmMsg) (*hbft.ReplyMsg, error)

HandlePreConfirmMsg can be called when the node receives a pre-confirm message.

func (*Node) HandleReq

func (node *Node) HandleReq(reqMsg *hbft.RequestMsg) (*hbft.PreConfirmMsg, error)

HandleReq can be called when our node starting mining a block. Consensus start procedure for the Primary.

func (*Node) HbftEcRecover

func (node *Node) HbftEcRecover(data, sig []byte) (common.Address, error)

func (*Node) HbftProcess

func (node *Node) HbftProcess(msg interface{})

func (*Node) HbftSign

func (node *Node) HbftSign(address common.Address, passwd string, data []byte) ([]byte, error)

func (*Node) InitNodeTable

func (node *Node) InitNodeTable()

func (*Node) IsBusy

func (node *Node) IsBusy() bool

func (*Node) SendHBFTMsg

func (node *Node) SendHBFTMsg(msg interface{}, msgType hbft.TypeHBFTMsg)

func (*Node) SetBusy

func (node *Node) SetBusy(flag bool)

func (*Node) SubscribeChainHeadEvent

func (node *Node) SubscribeChainHeadEvent()

SubscribeChainHeadEvent Subscribes events from blockchain and start the loop

func (*Node) UpdateNodeTable

func (node *Node) UpdateNodeTable(lastSealer common.Address, lastTime int64, sealers []common.Address)

func (*Node) ValidateNewBlocks

func (node *Node) ValidateNewBlocks(preConfirmMsg *hbft.PreConfirmMsg) error

Jump to

Keyboard shortcuts

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