bftview

package
v0.0.0-...-9fbb145 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package bftview implements Cypherium committee common operation functions.

Index

Constants

View Source
const CommitteeCacheSize = 10

Variables

This section is empty.

Functions

func DeleteCommittee

func DeleteCommittee(keyBlockNumber uint64, hash common.Hash)

func DeleteMember

func DeleteMember(kNumber uint64, hash common.Hash)

func GetMemberIndex

func GetMemberIndex(pubKey string) int

func GetNodeID

func GetNodeID(addr string, pub string) string

func GetServerCommitteeLen

func GetServerCommitteeLen() int

func GetServerInfo

func GetServerInfo(infoType ServerInfoType) string

func IamLeader

func IamLeader(leaderIndex uint) bool

func IamMember

func IamMember() int

return the member's index in current committee

func IamMemberByNumber

func IamMemberByNumber(kNumber uint64, hash common.Hash) bool

func SetCommitteeConfig

func SetCommitteeConfig(db cphdb.Database, keyblockchain KeyBlockChainInterface, service ServiceInterface)

func SetServerInfo

func SetServerInfo(address, pubKey string)

func StrToBlsPrivKey

func StrToBlsPrivKey(s string) *bls.SecretKey

func StrToBlsPubKey

func StrToBlsPubKey(s string) *bls.PublicKey

func ToBlsPublicKeys

func ToBlsPublicKeys(hash common.Hash) []*bls.PublicKey

------Tools---------------------------------------------------------------------------------------------------------

func WriteCommittee

func WriteCommittee(keyBlockNumber uint64, hash common.Hash, cm *Committee) bool

Types

type Committee

type Committee struct {
	List []*common.Cnode `rlp:"nil"`
}

type Committee []*common.Cnode

func GetCommittee

func GetCommittee(newNode *common.Cnode, keyblock *types.KeyBlock, needIp bool) (mb *Committee, outer *common.Cnode)

func GetCurrentMember

func GetCurrentMember() *Committee

func LoadMember

func LoadMember(kNumber uint64, hash common.Hash, needIP bool) *Committee

load committee by keyblock number, needIP is for ignore ip address

func ReadCommittee

func ReadCommittee(keyBlockNumber uint64, hash common.Hash) *Committee

ReadCommittee retrieves the committee.

func (*Committee) Add

func (committee *Committee) Add(r *common.Cnode, leaderIndex int, outAddress string) *common.Cnode

Add member node to committee, one in and one out

func (*Committee) Copy

func (committee *Committee) Copy() *Committee

func (*Committee) Get

func (committee *Committee) Get(key string, findType ServerInfoType) (*common.Cnode, int)

func (*Committee) HasIP

func (committee *Committee) HasIP() bool

func (*Committee) In

func (committee *Committee) In() *common.Cnode

func (*Committee) Leader

func (committee *Committee) Leader() *common.Cnode

func (*Committee) RlpHash

func (committee *Committee) RlpHash() (h common.Hash)

func (*Committee) Store

func (committee *Committee) Store(keyblock *types.KeyBlock) bool

func (*Committee) Store0

func (committee *Committee) Store0(keyblock *types.KeyBlock) bool

func (*Committee) ToBlsPublicKeys

func (committee *Committee) ToBlsPublicKeys(hash common.Hash) []*bls.PublicKey

Convert committee's public key to bls public key

type CommitteeConfig

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

type KeyBlockChainInterface

type KeyBlockChainInterface interface {
	CurrentBlock() *types.KeyBlock
	CurrentBlockN() uint64
	GetBlockByHash(hash common.Hash) *types.KeyBlock
	CurrentCommittee() []*common.Cnode
}

type ServerInfo

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

type ServerInfoType

type ServerInfoType int
const (
	PublicKey ServerInfoType = iota
	PrivateKey
	Address
	ID
)

type ServiceInterface

type ServiceInterface interface {
	Committee_OnStored(*types.KeyBlock, *Committee)
	Committee_Request(kNumber uint64, hash common.Hash)
}

type View

type View struct {
	TxNumber      uint64
	TxHash        common.Hash
	KeyNumber     uint64
	KeyHash       common.Hash
	CommitteeHash common.Hash
	LeaderIndex   uint
	ReconfigType  uint8
}

func DecodeToView

func DecodeToView(data []byte) *View

func (*View) DecodeRLP

func (v *View) DecodeRLP(s *rlp.Stream) error

func (*View) EncodeRLP

func (v *View) EncodeRLP(w io.Writer) error

func (*View) EncodeToBytes

func (v *View) EncodeToBytes() []byte

func (*View) EqualAll

func (v *View) EqualAll(other *View) bool

Check for identity

func (*View) EqualNoIndex

func (v *View) EqualNoIndex(other *View) bool

Check for identity except index

func (*View) Hash

func (v *View) Hash() (h common.Hash)

type ViewExt

type ViewExt struct {
	TxNumber      uint64
	TxHash        common.Hash
	KeyNumber     uint64
	KeyHash       common.Hash
	CommitteeHash common.Hash
	LeaderIndex   uint
	ReconfigType  uint8
}

Jump to

Keyboard shortcuts

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