epoch

package
v0.0.0-...-6e04e41 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The reason code for delete epoch member
	DelCode_Disconnect      = 1
	DelCode_NoBlockProduced = 2
)
View Source
const (
	DelEpochMemberResult_NotConfirm = uint32(0)
	DelEpochMemberResult_Agree      = uint32(1)
	DelEpochMemberResult_Reject     = uint32(2)
)
View Source
const (
	Pos_Epoch_NotStarted = -1
)

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type DelEpochMember

type DelEpochMember struct {
	// validator id
	ValidatorId    uint64 // The validator id for confirm epoch member delete
	DelValidatorId uint64 // The validator id to be deleted
	DelCode        uint32 // The reason code for delete epoch member
	EpochIndex     int64  // The epoch index for confirm epoch member delete
	Result         uint32 // The result for confirm, DelEpochMemberResult_NotConfirm, DelEpochMemberResult_Agree, DelEpochMemberResult_Reject
	Token          string // The token for epoch handover, it sign by validator to be confirmed
}

Confirm to delete an epoch member from the current epoch list

func (*DelEpochMember) GetDelEpochMemTokenData

func (he *DelEpochMember) GetDelEpochMemTokenData() []byte

func (*DelEpochMember) VerifyToken

func (he *DelEpochMember) VerifyToken(pubKey []byte) bool

type Epoch

type Epoch struct {
	EpochIndex      int64                // Epoch Index, start from 0
	CreateHeight    int32                // 创建Epoch时当前Block的高度
	CreateTime      time.Time            // 当前Epoch的创建时间
	ItemList        []*EpochItem         // 当前Epoch包含的验证者列表,(已排序), 在一个Epoch结束前不会改变
	Generator       *generator.Generator // 当前Generator
	CurGeneratorPos int32                // 当前Generator在ItemList中的位置
	//	CurrentHeight uint64             // 当前Block chain的高度
	LastChangeTime time.Time       // 最后一次改变的时间, 用于判断是否需要更新, Epoch的改变包括创建, 转正,generator流转,成员删除
	VCBlockHeight  int64           // 记录当前epoch改变的的VCblock高度
	VCBlockHash    *chainhash.Hash // 记录当前epoch改变的的VCblock hash
}

func NewEpoch

func NewEpoch() *Epoch

func (*Epoch) AddValidatorToEpoch

func (e *Epoch) AddValidatorToEpoch(validatorInfo *validatorinfo.ValidatorInfo) error

func (*Epoch) DelEpochMember

func (e *Epoch) DelEpochMember(validatorId uint64) error

func (*Epoch) GetCreateTime

func (e *Epoch) GetCreateTime() time.Time

func (*Epoch) GetCurGeneratorPos

func (e *Epoch) GetCurGeneratorPos() int32

func (*Epoch) GetGenerator

func (e *Epoch) GetGenerator() *generator.Generator

func (*Epoch) GetMemberCount

func (e *Epoch) GetMemberCount() int32

func (*Epoch) GetMemberValidatorId

func (e *Epoch) GetMemberValidatorId(pos int32) uint64

func (*Epoch) GetNextValidator

func (e *Epoch) GetNextValidator() *EpochItem

func (*Epoch) GetNextValidatorByEpochOrder

func (e *Epoch) GetNextValidatorByEpochOrder() *EpochItem

func (*Epoch) GetValidatorList

func (e *Epoch) GetValidatorList() []*EpochItem

func (*Epoch) GetValidatorPos

func (e *Epoch) GetValidatorPos(validatorId uint64) int32

func (*Epoch) IsExist

func (e *Epoch) IsExist(validatorId uint64) bool

func (*Epoch) IsLastGenerator

func (e *Epoch) IsLastGenerator() bool

func (*Epoch) IsValidEpochValidator

func (e *Epoch) IsValidEpochValidator(validatorInfo *validatorinfo.ValidatorInfo) bool

func (*Epoch) ToNextGenerator

func (e *Epoch) ToNextGenerator(generator *generator.Generator) error

func (*Epoch) UpdateGenerator

func (e *Epoch) UpdateGenerator(generator *generator.Generator)

func (*Epoch) VoteGenerator

func (e *Epoch) VoteGenerator() *EpochItem

type EpochItem

type EpochItem struct {
	ValidatorId uint64
	Host        string
	PublicKey   [btcec.PubKeyBytesLenCompressed]byte
	Index       uint32 // 第一次生成是确定的,后续不会改变, 当Epoch的Validators有改变(下线)时,保证EpochItem的Index不发生改变
}

type HandOverEpoch

type HandOverEpoch struct {
	// Request validator id
	ValidatorId    uint64
	Timestamp      int64  // The time of generator hand over, it should be time of completed miner last block
	Token          string // The token for epoch handover, it sign by current generator (HandOver), if the type is New Epoch, it is signed by Epoch Requester (Epoch member)
	NextEpochIndex int64  // Next epoch index
	NextHeight     int32  // The next block height
}

func (*HandOverEpoch) GetNextEpochTokenData

func (he *HandOverEpoch) GetNextEpochTokenData() []byte

func (*HandOverEpoch) VerifyToken

func (he *HandOverEpoch) VerifyToken(pubKey []byte) bool

type NewEpochVote

type NewEpochVote struct {
	NewEpoch  *Epoch
	Reason    uint32
	VotorId   uint64
	PublicKey [btcec.PubKeyBytesLenCompressed]byte
	Token     string
	Hash      *chainhash.Hash // epoch block hash
}

func (*NewEpochVote) Encode

func (nev *NewEpochVote) Encode(w io.Writer) error

func (*NewEpochVote) GetTokenData

func (nev *NewEpochVote) GetTokenData() []byte

func (*NewEpochVote) VerifyToken

func (nev *NewEpochVote) VerifyToken(pubKey []byte) bool

Jump to

Keyboard shortcuts

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