common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SOLO_POLICY        = "solo"
	SOLO_CONSENSUS_NUM = uint8(1)
	BFT_POLICY         = "bft"
	FBFT_POLICY        = "fbft"
	DBFT_POLICY        = "dbft"
)
View Source
const (
	MAX_BUF_LEN        = 1024 * 256
	DefaultViewNum     = uint64(0)
	DefaultWalterLevel = int64(1)
)
View Source
const (
	NullSignal = MessageSignal(iota)
	ReceiveResponseSignal
)
View Source
const (
	NullState = contentState(iota)
	Initial
	InConsensus
	ToConsensus
)

Variables

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

Functions

func HeaderHash

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

func Sum

func Sum(bz []byte) []byte

Types

type ConsensusPlugin

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

func NewConsensusPlugin

func NewConsensusPlugin() *ConsensusPlugin

func (*ConsensusPlugin) Add

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

func (*ConsensusPlugin) GetContentByHash

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

func (*ConsensusPlugin) Remove

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

type ConsensusResult

type ConsensusResult struct {
	View        uint64
	Participate []account.Account
	Roles       map[account.Account]common.Roler
}

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 (self *Content) AddSignature(account account.Account, sign []byte) bool

func (*Content) GetContentPayloadByHash

func (self *Content) GetContentPayloadByHash(digest types.Hash) interface{}

func (*Content) GetSignByAccount

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

func (*Content) GetSignMap

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

func (*Content) SetState

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

func (*Content) Signatures

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

func (*Content) State

func (self *Content) State() contentState

type MessageSignal

type MessageSignal uint8

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 Version

type Version uint64

type ViewChange

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

func NewViewChange

func NewViewChange() *ViewChange

func (*ViewChange) AddViewRequest

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

func (*ViewChange) GetCurrentViewNum

func (self *ViewChange) GetCurrentViewNum() uint64

func (*ViewChange) GetRequestByViewNum

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

func (*ViewChange) GetWalterLevel

func (self *ViewChange) GetWalterLevel() int64

func (*ViewChange) RemoveRequest

func (self *ViewChange) RemoveRequest(viewNum uint64)

func (*ViewChange) SetCurrentViewNum

func (self *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 (self *ViewRequests) GetReceivedAccounts() []account.Account

func (*ViewRequests) GetViewRequestState

func (self *ViewRequests) GetViewRequestState() ViewRequestState

func (*ViewRequests) ReceiveViewRequestByAccount

func (self *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