common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: Apache-2.0 Imports: 11 Imported by: 7

Documentation

Index

Constants

View Source
const (
	SoloPolicy       = "solo"
	SoloConsensusNum = uint8(1)
	BftPolicy        = "bft"
	FbftPolicy       = "fbft"
	DbftPolicy       = "dbft"
)
View Source
const (
	MaxBufferLen       = 1024 * 256
	DefaultViewNum     = uint64(0)
	DefaultWalterLevel = int64(1)
	DefaultBlockHeight = uint64(0)
)
View Source
const (
	Initial
	InConsensus
	ToConsensus
)
View Source
const (
	ReceiveResponseSignal
)

Variables

View Source
var (
	ErrorsNewRepositoryByBlockHash = errors.New("get block chain by hash failed")
)

Functions

func HashAlg added in v1.0.0

func HashAlg() hash.Hash

func HeaderHash

func HeaderHash(block *types.Block) types.Hash

Types

type ConsensusPlugin

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

func NewConsensusPlugin

func NewConsensusPlugin() *ConsensusPlugin

func (*ConsensusPlugin) Add

func (instance *ConsensusPlugin) Add(digest types.Hash, payload interface{}) *Content

func (*ConsensusPlugin) GetContentByHash

func (instance *ConsensusPlugin) GetContentByHash(digest types.Hash) (*Content, error)

func (*ConsensusPlugin) GetLatestBlockHeight added in v0.3.0

func (instance *ConsensusPlugin) GetLatestBlockHeight() uint64

func (*ConsensusPlugin) Remove

func (instance *ConsensusPlugin) Remove(digest types.Hash)

func (*ConsensusPlugin) SetLatestBlockHeight added in v0.3.0

func (instance *ConsensusPlugin) SetLatestBlockHeight(height uint64)

type ConsensusResult

type ConsensusResult struct {
	View        uint64
	Participate []account.Account
	Master      account.Account
}

type ConsensusStatus

type ConsensusStatus uint8
const (
	Proposing ConsensusStatus = iota // Proposing --> 0  prepare to launch a proposal
	Propose                          // Propose --> 1 propose for a proposal
	Approve                          // Approve --> 2 response of participate which accept the proposal
	Reject                           // Reject --> 3 response of participate which reject the proposal
	Committed                        // Committed --> 4 proposal has been accepted by participates with consensus policy
)

type Content

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

func (*Content) AddSignature

func (instance *Content) AddSignature(account account.Account, sign []byte) bool

func (*Content) GetContentPayload added in v0.3.0

func (instance *Content) GetContentPayload() interface{}

func (*Content) GetSignByAccount

func (instance *Content) GetSignByAccount(account account.Account) ([]byte, bool)

func (*Content) GetSignMap

func (instance *Content) GetSignMap() map[account.Account][]byte

func (*Content) SetState

func (instance *Content) SetState(state contentState) error

func (*Content) Signatures

func (instance *Content) Signatures() [][]byte

func (*Content) State

func (instance *Content) State() contentState

type MessageSignal

type MessageSignal uint8

type OnlineState added in v0.3.0

type OnlineState string
const GoOnline OnlineState = "GoOnline"
const Online OnlineState = "Online"

type OnlineWizard added in v0.3.0

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

func NewOnlineWizard added in v0.3.0

func NewOnlineWizard() *OnlineWizard

func (*OnlineWizard) AddOnlineResponse added in v0.3.0

func (instance *OnlineWizard) AddOnlineResponse(blockHeight uint64, nodes []account.Account, walterLevel int, master account.Account, viewNum uint64) ([]account.Account, OnlineState)

func (*OnlineWizard) DeleteOnlineResponse added in v0.3.0

func (instance *OnlineWizard) DeleteOnlineResponse(blockHeight uint64)

func (*OnlineWizard) GetCurrentHeight added in v0.3.0

func (instance *OnlineWizard) GetCurrentHeight() uint64

func (*OnlineWizard) GetCurrentState added in v0.3.0

func (instance *OnlineWizard) GetCurrentState() OnlineState

func (*OnlineWizard) GetCurrentStateByHeight added in v0.3.0

func (instance *OnlineWizard) GetCurrentStateByHeight(blockHeight uint64) OnlineState

func (*OnlineWizard) GetMasterByBlockHeight added in v0.3.0

func (instance *OnlineWizard) GetMasterByBlockHeight(blockHeight uint64) account.Account

func (*OnlineWizard) GetResponseNodesStateByBlockHeight added in v0.3.0

func (instance *OnlineWizard) GetResponseNodesStateByBlockHeight(blockHeight uint64) OnlineState

type Proposal

type Proposal struct {
	Block     *types.Block
	Timestamp int64
}

Base proposal

type Request

type Request struct {
	Id      uint64
	Payload *Proposal
	Status  ConsensusStatus
}

BFTRequest that with bft policy

type ResponseNodes added in v0.3.0

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

func NewResponseNodes added in v0.3.0

func NewResponseNodes(walterLevel int, master account.Account) *ResponseNodes

func (*ResponseNodes) AddResponseNodes added in v0.3.0

func (instance *ResponseNodes) AddResponseNodes(node account.Account) ([]account.Account, OnlineState)

func (*ResponseNodes) GetResponseState added in v0.3.0

func (instance *ResponseNodes) GetResponseState() OnlineState

type Version

type Version uint64

type ViewChange

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

func NewViewChange

func NewViewChange() *ViewChange

func (*ViewChange) AddViewRequest

func (instance *ViewChange) AddViewRequest(viewNum uint64, toChange uint8) (*ViewRequests, error)

func (*ViewChange) GetCurrentViewNum

func (instance *ViewChange) GetCurrentViewNum() uint64

func (*ViewChange) GetRequestByViewNum

func (instance *ViewChange) GetRequestByViewNum(viewNum uint64) *ViewRequests

func (*ViewChange) GetWalterLevel

func (instance *ViewChange) GetWalterLevel() int64

func (*ViewChange) RemoveRequest

func (instance *ViewChange) RemoveRequest()

func (*ViewChange) SetCurrentViewNum

func (instance *ViewChange) SetCurrentViewNum(newViewNum uint64)

type ViewRequestState

type ViewRequestState string
const ViewEnd ViewRequestState = "ViewEnd"
const Viewing ViewRequestState = "Viewing"

type ViewRequests

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

func NewRequests

func NewRequests(toChange uint8) *ViewRequests

func (*ViewRequests) GetReceivedAccounts

func (instance *ViewRequests) GetReceivedAccounts() []account.Account

func (*ViewRequests) GetViewRequestState

func (instance *ViewRequests) GetViewRequestState() ViewRequestState

func (*ViewRequests) ReceiveViewRequestByAccount

func (instance *ViewRequests) ReceiveViewRequestByAccount(account account.Account) ViewRequestState

type ViewStatus

type ViewStatus string
const ViewChanging ViewStatus = "ViewChanging"
const ViewNormal ViewStatus = "ViewNormal"

Jump to

Keyboard shortcuts

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