Documentation ¶
Index ¶
- Constants
- Variables
- func DisableLog()
- func NewArbitrators(chainParams *config.Params, committee *state.Committee, ...) (*arbitrators, error)
- func SerializeArbiterMember(ar ArbiterMember, w io.Writer) (err error)
- func UseLogger(logger elalog.Logger)
- type ArbiterInfo
- type ArbiterMember
- func ArbiterMemberFromReader(r io.Reader) (result ArbiterMember, err error)
- func NewCRCArbiter(nodePK []byte, ownerPK []byte, cr *state.CRMember, isNormal bool) (ArbiterMember, error)
- func NewDPoSArbiter(producer *Producer) (ArbiterMember, error)
- func NewOriginArbiter(key []byte) (ArbiterMember, error)
- type ArbiterType
- type Arbitrators
- type ArbitratorsMock
- func (a *ArbitratorsMock) CRCProducerCount() int
- func (a *ArbitratorsMock) CheckCRCAppropriationTx(block *types.Block) error
- func (a *ArbitratorsMock) CheckCustomIDResultsTx(block *types.Block) error
- func (a *ArbitratorsMock) CheckDPOSIllegalTx(block *types.Block) error
- func (a *ArbitratorsMock) CheckNextTurnDPOSInfoTx(block *types.Block) error
- func (a *ArbitratorsMock) CheckRevertToDPOSTX(block *types.Block) error
- func (a *ArbitratorsMock) DumpInfo(height uint32)
- func (a *ArbitratorsMock) GetAllProducersPublicKey() []string
- func (a *ArbitratorsMock) GetArbitersCount() int
- func (a *ArbitratorsMock) GetArbitersMajorityCount() int
- func (a *ArbitratorsMock) GetArbitersRoundReward() map[common.Uint168]common.Fixed64
- func (a *ArbitratorsMock) GetArbitrators() []*ArbiterInfo
- func (a *ArbitratorsMock) GetCRCArbiters() []*ArbiterInfo
- func (a *ArbitratorsMock) GetCRCArbitersCount() int
- func (a *ArbitratorsMock) GetCandidates() [][]byte
- func (a *ArbitratorsMock) GetConnectedProducer(publicKey []byte) ArbiterMember
- func (a *ArbitratorsMock) GetCrossChainArbiters() []*ArbiterInfo
- func (a *ArbitratorsMock) GetCrossChainArbitersCount() int
- func (a *ArbitratorsMock) GetCrossChainArbitersMajorityCount() int
- func (a *ArbitratorsMock) GetCurrentRewardData() RewardData
- func (a *ArbitratorsMock) GetDutyChangeCount() int
- func (a *ArbitratorsMock) GetDutyChangedCount() int
- func (a *ArbitratorsMock) GetDutyIndex() int
- func (a *ArbitratorsMock) GetDutyIndexByHeight(uint32) int
- func (a *ArbitratorsMock) GetFinalRoundChange() common.Fixed64
- func (a *ArbitratorsMock) GetLastBlockTimestamp() uint32
- func (a *ArbitratorsMock) GetNeedConnectArbiters() []peer.PID
- func (a *ArbitratorsMock) GetNextArbitrators() []*ArbiterInfo
- func (a *ArbitratorsMock) GetNextCRCArbiters() [][]byte
- func (a *ArbitratorsMock) GetNextCandidates() [][]byte
- func (a *ArbitratorsMock) GetNextOnDutyArbitrator(offset uint32) []byte
- func (a *ArbitratorsMock) GetNextRewardData() RewardData
- func (a *ArbitratorsMock) GetNormalArbitrators() ([][]byte, error)
- func (a *ArbitratorsMock) GetOnDutyArbitrator() []byte
- func (a *ArbitratorsMock) GetOnDutyCrossChainArbitrator() []byte
- func (a *ArbitratorsMock) GetRevertToPOWBlockHeight() uint32
- func (a *ArbitratorsMock) GetSnapshot(height uint32) []*CheckPoint
- func (a *ArbitratorsMock) HasArbitersMajorityCount(num int) bool
- func (a *ArbitratorsMock) HasArbitersMinorityCount(num int) bool
- func (a *ArbitratorsMock) IsActiveProducer(pk []byte) bool
- func (a *ArbitratorsMock) IsArbitrator(pk []byte) bool
- func (a *ArbitratorsMock) IsCRCArbitrator(pk []byte) bool
- func (a *ArbitratorsMock) IsDisabledProducer(pk []byte) bool
- func (a *ArbitratorsMock) IsInPOWMode() bool
- func (a *ArbitratorsMock) IsInactiveMode() bool
- func (a *ArbitratorsMock) IsMemberElectedNextCRCArbitrator(pk []byte) bool
- func (a *ArbitratorsMock) IsNeedNextTurnDPOSInfo() bool
- func (a *ArbitratorsMock) IsNextCRCArbitrator(pk []byte) bool
- func (a *ArbitratorsMock) IsUnderstaffedMode() bool
- func (a *ArbitratorsMock) ProcessSpecialTxPayload(p types.Payload, height uint32) error
- func (a *ArbitratorsMock) RecoverFromCheckPoints(height uint32) (uint32, error)
- func (a *ArbitratorsMock) SetArbitrators(ar []ArbiterMember)
- func (a *ArbitratorsMock) SetCandidates(ca []ArbiterMember)
- func (a *ArbitratorsMock) SetDutyChangeCount(count int)
- func (a *ArbitratorsMock) SetDutyChangedCount(count int)
- func (a *ArbitratorsMock) SetNeedRevertToDPOSTX(need bool)
- func (a *ArbitratorsMock) SetNextArbitrators(ar []ArbiterMember)
- func (a *ArbitratorsMock) SetNextCandidates(ca []ArbiterMember)
- func (a *ArbitratorsMock) Start()
- type ChangeType
- type CheckPoint
- func (c *CheckPoint) DataExtension() string
- func (c *CheckPoint) Deserialize(r io.Reader) (err error)
- func (c *CheckPoint) EffectivePeriod() uint32
- func (c *CheckPoint) Generator() func(buf []byte) checkpoint.ICheckPoint
- func (c *CheckPoint) GetHeight() uint32
- func (c *CheckPoint) Key() string
- func (c *CheckPoint) LogError(err error)
- func (c *CheckPoint) OnBlockSaved(block *types.DposBlock)
- func (c *CheckPoint) OnInit()
- func (c *CheckPoint) OnRollbackSeekTo(height uint32)
- func (c *CheckPoint) OnRollbackTo(height uint32) error
- func (c *CheckPoint) Priority() checkpoint.Priority
- func (c *CheckPoint) SavePeriod() uint32
- func (c *CheckPoint) Serialize(w io.Writer) (err error)
- func (c *CheckPoint) SetHeight(height uint32)
- func (c *CheckPoint) Snapshot() checkpoint.ICheckPoint
- func (c *CheckPoint) StartHeight() uint32
- type ConsesusAlgorithm
- type IArbitratorsRecord
- type Producer
- func (p *Producer) ActivateRequestHeight() uint32
- func (p *Producer) AvailableAmount() common.Fixed64
- func (p *Producer) CancelHeight() uint32
- func (p *Producer) DepositAmount() common.Fixed64
- func (p *Producer) Deserialize(r io.Reader) (err error)
- func (p *Producer) IllegalHeight() uint32
- func (p *Producer) InactiveSince() uint32
- func (p *Producer) Info() payload.ProducerInfo
- func (p *Producer) NodePublicKey() []byte
- func (p *Producer) OwnerPublicKey() []byte
- func (p *Producer) Penalty() common.Fixed64
- func (p *Producer) RegisterHeight() uint32
- func (p *Producer) Serialize(w io.Writer) error
- func (p *Producer) State() ProducerState
- func (p *Producer) TotalAmount() common.Fixed64
- func (p *Producer) Votes() common.Fixed64
- type ProducerState
- type RewardData
- type State
- func (s *State) ExistProducerByDepositHash(programHash common.Uint168) bool
- func (s *State) GetActiveProducers() []*Producer
- func (s *State) GetAllProducers() []*Producer
- func (s *State) GetAllProducersPublicKey() []string
- func (s *State) GetCanceledProducers() []*Producer
- func (s *State) GetConsensusAlgorithm() ConsesusAlgorithm
- func (s *State) GetHistory(height uint32) (*StateKeyFrame, error)
- func (s *State) GetIllegalProducers() []*Producer
- func (s *State) GetInactiveProducers() []*Producer
- func (s *State) GetLastIrreversibleHeight() uint32
- func (s *State) GetPendingCanceledProducers() []*Producer
- func (s *State) GetPendingProducers() []*Producer
- func (s *State) GetProducer(publicKey []byte) *Producer
- func (s *State) GetProducers() []*Producer
- func (s *State) GetReturnedDepositProducers() []*Producer
- func (s *State) GetVotedProducers() []*Producer
- func (s *State) IsAbleToRecoverFromInactiveMode() bool
- func (s *State) IsAbleToRecoverFromUnderstaffedState() bool
- func (s *State) IsActiveProducer(publicKey []byte) bool
- func (s *State) IsCanceledProducer(publicKey []byte) bool
- func (s *State) IsDPOSTransaction(tx *types.Transaction) bool
- func (s *State) IsIllegalProducer(publicKey []byte) bool
- func (s *State) IsInactiveProducer(publicKey []byte) bool
- func (s *State) IsIrreversible(curBlockHeight uint32, detachNodesLen int) bool
- func (s *State) IsPendingProducer(publicKey []byte) bool
- func (s *State) LeaveEmergency(history *utils.History, height uint32)
- func (s *State) NicknameExists(nickname string) bool
- func (s *State) ProcessBlock(block *types.Block, confirm *payload.Confirm)
- func (s *State) ProcessSpecialTxPayload(p types.Payload, height uint32)
- func (s *State) ProcessVoteStatisticsBlock(block *types.Block)
- func (s *State) ProducerExists(publicKey []byte) bool
- func (s *State) ProducerNodePublicKeyExists(publicKey []byte) bool
- func (s *State) ProducerOwnerPublicKeyExists(publicKey []byte) bool
- func (s *State) RemoveSpecialTx(hash common.Uint256)
- func (s *State) RollbackSeekTo(height uint32)
- func (s *State) RollbackTo(height uint32) error
- func (s *State) SpecialTxExists(tx *types.Transaction) bool
- type StateKeyFrame
- func (s *StateKeyFrame) Deserialize(r io.Reader) (err error)
- func (s *StateKeyFrame) DeserializeDIDSet(r io.Reader) (vmap map[common.Uint168]struct{}, err error)
- func (s *StateKeyFrame) DeserializeFixed64Map(r io.Reader) (vmap map[string]common.Fixed64, err error)
- func (s *StateKeyFrame) DeserializeHashSet(r io.Reader) (vmap map[common.Uint256]struct{}, err error)
- func (s *StateKeyFrame) DeserializeProducerMap(r io.Reader) (pmap map[string]*Producer, err error)
- func (s *StateKeyFrame) DeserializeStringMap(r io.Reader) (smap map[string]string, err error)
- func (s *StateKeyFrame) DeserializeStringSet(r io.Reader) (vmap map[string]struct{}, err error)
- func (s *StateKeyFrame) Serialize(w io.Writer) (err error)
- func (s *StateKeyFrame) SerializeDIDSet(vmap map[common.Uint168]struct{}, w io.Writer) (err error)
- func (s *StateKeyFrame) SerializeFixed64Map(vmap map[string]common.Fixed64, w io.Writer) (err error)
- func (s *StateKeyFrame) SerializeHashSet(vmap map[common.Uint256]struct{}, w io.Writer) (err error)
- func (s *StateKeyFrame) SerializeProducerMap(pmap map[string]*Producer, w io.Writer) (err error)
- func (s *StateKeyFrame) SerializeStringMap(smap map[string]string, w io.Writer) (err error)
- func (s *StateKeyFrame) SerializeStringSet(vmap map[string]struct{}, w io.Writer) (err error)
Constants ¶
const ( // MajoritySignRatioNumerator defines the ratio numerator to achieve // majority signatures. MajoritySignRatioNumerator = float64(2) // MajoritySignRatioDenominator defines the ratio denominator to achieve // majority signatures. MajoritySignRatioDenominator = float64(3) // MaxNormalInactiveChangesCount defines the max count arbitrators can // change when more than 1/3 arbiters don't sign cause to confirm fail MaxNormalInactiveChangesCount = 3 // MaxSnapshotLength defines the max length the snapshot map should take MaxSnapshotLength = 20 )
const ( // CheckpointKey defines key of DPoS checkpoint. CheckpointKey = "cp_dpos" // CheckPointInterval defines interval height between two neighbor check // points. CheckPointInterval = uint32(720) )
const ( DSNormal degradationState = 0x00 DSUnderstaffed degradationState = 0x01 DSInactive degradationState = 0x02 )
const ( // ActivateDuration is about how long we should activate from pending or // inactive state ActivateDuration = 6 )
const CacheVotesSize = 6
CacheVotesSize indicate the size to cache votes information.
const IrreversibleHeight = 6
IrreversibleHeight defines the max height that the chain be reorganized
Variables ¶
var (
ErrInsufficientProducer = errors.New("producers count less than min arbitrators count")
)
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func NewArbitrators ¶
func NewArbitrators(chainParams *config.Params, committee *state.Committee, getProducerDepositAmount func(common.Uint168) (common.Fixed64, error), tryUpdateCRMemberInactivity func(did common.Uint168, needReset bool, height uint32), tryRevertCRMemberInactivityfunc func(did common.Uint168, oriState state.MemberState, oriInactiveCount uint32, height uint32), tryUpdateCRMemberIllegal func(did common.Uint168, height uint32), tryRevertCRMemberIllegal func(did common.Uint168, oriState state.MemberState, height uint32)) ( *arbitrators, error)
func SerializeArbiterMember ¶ added in v0.5.0
func SerializeArbiterMember(ar ArbiterMember, w io.Writer) (err error)
Types ¶
type ArbiterInfo ¶ added in v0.7.0
type ArbiterMember ¶ added in v0.5.0
type ArbiterMember interface { common.Serializable GetType() ArbiterType GetOwnerPublicKey() []byte GetOwnerProgramHash() common.Uint168 GetNodePublicKey() []byte Clone() ArbiterMember IsNormal() bool }
func ArbiterMemberFromReader ¶ added in v0.5.0
func ArbiterMemberFromReader(r io.Reader) (result ArbiterMember, err error)
func NewCRCArbiter ¶ added in v0.5.0
func NewDPoSArbiter ¶ added in v0.5.0
func NewDPoSArbiter(producer *Producer) (ArbiterMember, error)
func NewOriginArbiter ¶ added in v0.5.0
func NewOriginArbiter(key []byte) (ArbiterMember, error)
type ArbiterType ¶ added in v0.5.0
type ArbiterType uint8
const ( Origin ArbiterType = 0x00 DPoS ArbiterType = 0x01 CROrigin ArbiterType = 0x02 CRC ArbiterType = 0x03 )
type Arbitrators ¶
type Arbitrators interface { Start() CheckDPOSIllegalTx(block *types.Block) error ProcessSpecialTxPayload(p types.Payload, height uint32) error CheckCRCAppropriationTx(block *types.Block) error CheckNextTurnDPOSInfoTx(block *types.Block) error CheckCustomIDResultsTx(block *types.Block) error CheckRevertToDPOSTX(block *types.Block) error IsArbitrator(pk []byte) bool IsNextCRCArbitrator(pk []byte) bool IsMemberElectedNextCRCArbitrator(pk []byte) bool GetArbitrators() []*ArbiterInfo GetCandidates() [][]byte GetAllProducersPublicKey() []string GetNextArbitrators() []*ArbiterInfo GetNextCandidates() [][]byte GetNeedConnectArbiters() []peer.PID GetDutyIndexByHeight(height uint32) int GetDutyIndex() int GetCurrentRewardData() RewardData GetNextRewardData() RewardData GetArbitersRoundReward() map[common.Uint168]common.Fixed64 GetFinalRoundChange() common.Fixed64 SetNeedRevertToDPOSTX(need bool) IsInPOWMode() bool GetRevertToPOWBlockHeight() uint32 GetLastBlockTimestamp() uint32 IsInactiveMode() bool IsUnderstaffedMode() bool GetConnectedProducer(publicKey []byte) ArbiterMember GetCRCArbiters() []*ArbiterInfo GetNextCRCArbiters() [][]byte CRCProducerCount() int IsCRCArbitrator(pk []byte) bool IsActiveProducer(pk []byte) bool IsDisabledProducer(pk []byte) bool IsNeedNextTurnDPOSInfo() bool GetOnDutyArbitrator() []byte GetNextOnDutyArbitrator(offset uint32) []byte GetOnDutyCrossChainArbitrator() []byte GetCrossChainArbiters() []*ArbiterInfo GetCrossChainArbitersCount() int GetCrossChainArbitersMajorityCount() int GetArbitersCount() int GetCRCArbitersCount() int GetArbitersMajorityCount() int HasArbitersMajorityCount(num int) bool HasArbitersMinorityCount(num int) bool GetSnapshot(height uint32) []*CheckPoint DumpInfo(height uint32) }
type ArbitratorsMock ¶
type ArbitratorsMock struct { CurrentArbitrators []ArbiterMember CRCArbitrators []ArbiterMember NextCRCArbitrators []ArbiterMember CurrentCandidates []ArbiterMember NextArbitrators []ArbiterMember NextCandidates []ArbiterMember CurrentOwnerProgramHashes []*common.Uint168 CandidateOwnerProgramHashes []*common.Uint168 ArbitersRoundReward map[common.Uint168]common.Fixed64 OwnerVotesInRound map[common.Uint168]common.Fixed64 CRCArbitratorsMap map[string]*Producer TotalVotesInRound common.Fixed64 DutyChangedCount int MajorityCount int FinalRoundChange common.Fixed64 LastBlockTimestamp uint32 InactiveMode bool ActiveProducer []ArbiterMember Snapshot []*CheckPoint CurrentReward RewardData NextReward RewardData }
mock object of arbitrators
func NewArbitratorsMock ¶
func NewArbitratorsMock(arbitersByte []ArbiterMember, changeCount, majorityCount int) *ArbitratorsMock
func (*ArbitratorsMock) CRCProducerCount ¶ added in v0.5.0
func (a *ArbitratorsMock) CRCProducerCount() int
func (*ArbitratorsMock) CheckCRCAppropriationTx ¶ added in v0.5.0
func (a *ArbitratorsMock) CheckCRCAppropriationTx(block *types.Block) error
func (*ArbitratorsMock) CheckCustomIDResultsTx ¶ added in v0.7.0
func (a *ArbitratorsMock) CheckCustomIDResultsTx(block *types.Block) error
func (*ArbitratorsMock) CheckDPOSIllegalTx ¶ added in v0.3.2
func (a *ArbitratorsMock) CheckDPOSIllegalTx(block *types.Block) error
func (*ArbitratorsMock) CheckNextTurnDPOSInfoTx ¶ added in v0.7.0
func (a *ArbitratorsMock) CheckNextTurnDPOSInfoTx(block *types.Block) error
func (*ArbitratorsMock) CheckRevertToDPOSTX ¶ added in v0.7.0
func (a *ArbitratorsMock) CheckRevertToDPOSTX(block *types.Block) error
func (*ArbitratorsMock) DumpInfo ¶
func (a *ArbitratorsMock) DumpInfo(height uint32)
func (*ArbitratorsMock) GetAllProducersPublicKey ¶ added in v0.7.0
func (a *ArbitratorsMock) GetAllProducersPublicKey() []string
func (*ArbitratorsMock) GetArbitersCount ¶
func (a *ArbitratorsMock) GetArbitersCount() int
func (*ArbitratorsMock) GetArbitersMajorityCount ¶
func (a *ArbitratorsMock) GetArbitersMajorityCount() int
func (*ArbitratorsMock) GetArbitersRoundReward ¶ added in v0.3.2
func (a *ArbitratorsMock) GetArbitersRoundReward() map[common.Uint168]common.Fixed64
func (*ArbitratorsMock) GetArbitrators ¶
func (a *ArbitratorsMock) GetArbitrators() []*ArbiterInfo
func (*ArbitratorsMock) GetCRCArbiters ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCRCArbiters() []*ArbiterInfo
func (*ArbitratorsMock) GetCRCArbitersCount ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCRCArbitersCount() int
func (*ArbitratorsMock) GetCandidates ¶
func (a *ArbitratorsMock) GetCandidates() [][]byte
func (*ArbitratorsMock) GetConnectedProducer ¶ added in v0.5.0
func (a *ArbitratorsMock) GetConnectedProducer(publicKey []byte) ArbiterMember
func (*ArbitratorsMock) GetCrossChainArbiters ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCrossChainArbiters() []*ArbiterInfo
func (*ArbitratorsMock) GetCrossChainArbitersCount ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCrossChainArbitersCount() int
func (*ArbitratorsMock) GetCrossChainArbitersMajorityCount ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCrossChainArbitersMajorityCount() int
func (*ArbitratorsMock) GetCurrentRewardData ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCurrentRewardData() RewardData
func (*ArbitratorsMock) GetDutyChangeCount ¶
func (a *ArbitratorsMock) GetDutyChangeCount() int
func (*ArbitratorsMock) GetDutyChangedCount ¶
func (a *ArbitratorsMock) GetDutyChangedCount() int
func (*ArbitratorsMock) GetDutyIndex ¶
func (a *ArbitratorsMock) GetDutyIndex() int
func (*ArbitratorsMock) GetDutyIndexByHeight ¶
func (a *ArbitratorsMock) GetDutyIndexByHeight(uint32) int
func (*ArbitratorsMock) GetFinalRoundChange ¶ added in v0.3.2
func (a *ArbitratorsMock) GetFinalRoundChange() common.Fixed64
func (*ArbitratorsMock) GetLastBlockTimestamp ¶ added in v0.7.0
func (a *ArbitratorsMock) GetLastBlockTimestamp() uint32
func (*ArbitratorsMock) GetNeedConnectArbiters ¶
func (a *ArbitratorsMock) GetNeedConnectArbiters() []peer.PID
func (*ArbitratorsMock) GetNextArbitrators ¶
func (a *ArbitratorsMock) GetNextArbitrators() []*ArbiterInfo
func (*ArbitratorsMock) GetNextCRCArbiters ¶ added in v0.7.0
func (a *ArbitratorsMock) GetNextCRCArbiters() [][]byte
func (*ArbitratorsMock) GetNextCandidates ¶
func (a *ArbitratorsMock) GetNextCandidates() [][]byte
func (*ArbitratorsMock) GetNextOnDutyArbitrator ¶
func (a *ArbitratorsMock) GetNextOnDutyArbitrator(offset uint32) []byte
func (*ArbitratorsMock) GetNextRewardData ¶ added in v0.3.2
func (a *ArbitratorsMock) GetNextRewardData() RewardData
func (*ArbitratorsMock) GetNormalArbitrators ¶
func (a *ArbitratorsMock) GetNormalArbitrators() ([][]byte, error)
func (*ArbitratorsMock) GetOnDutyArbitrator ¶
func (a *ArbitratorsMock) GetOnDutyArbitrator() []byte
func (*ArbitratorsMock) GetOnDutyCrossChainArbitrator ¶ added in v0.3.2
func (a *ArbitratorsMock) GetOnDutyCrossChainArbitrator() []byte
func (*ArbitratorsMock) GetRevertToPOWBlockHeight ¶ added in v0.7.0
func (a *ArbitratorsMock) GetRevertToPOWBlockHeight() uint32
func (*ArbitratorsMock) GetSnapshot ¶ added in v0.3.2
func (a *ArbitratorsMock) GetSnapshot(height uint32) []*CheckPoint
func (*ArbitratorsMock) HasArbitersMajorityCount ¶
func (a *ArbitratorsMock) HasArbitersMajorityCount(num int) bool
func (*ArbitratorsMock) HasArbitersMinorityCount ¶
func (a *ArbitratorsMock) HasArbitersMinorityCount(num int) bool
func (*ArbitratorsMock) IsActiveProducer ¶ added in v0.3.2
func (a *ArbitratorsMock) IsActiveProducer(pk []byte) bool
func (*ArbitratorsMock) IsArbitrator ¶
func (a *ArbitratorsMock) IsArbitrator(pk []byte) bool
func (*ArbitratorsMock) IsCRCArbitrator ¶
func (a *ArbitratorsMock) IsCRCArbitrator(pk []byte) bool
func (*ArbitratorsMock) IsDisabledProducer ¶ added in v0.3.2
func (a *ArbitratorsMock) IsDisabledProducer(pk []byte) bool
func (*ArbitratorsMock) IsInPOWMode ¶ added in v0.7.0
func (a *ArbitratorsMock) IsInPOWMode() bool
func (*ArbitratorsMock) IsInactiveMode ¶ added in v0.3.2
func (a *ArbitratorsMock) IsInactiveMode() bool
func (*ArbitratorsMock) IsMemberElectedNextCRCArbitrator ¶ added in v0.7.0
func (a *ArbitratorsMock) IsMemberElectedNextCRCArbitrator(pk []byte) bool
func (*ArbitratorsMock) IsNeedNextTurnDPOSInfo ¶ added in v0.7.0
func (a *ArbitratorsMock) IsNeedNextTurnDPOSInfo() bool
func (*ArbitratorsMock) IsNextCRCArbitrator ¶ added in v0.7.0
func (a *ArbitratorsMock) IsNextCRCArbitrator(pk []byte) bool
func (*ArbitratorsMock) IsUnderstaffedMode ¶ added in v0.3.2
func (a *ArbitratorsMock) IsUnderstaffedMode() bool
func (*ArbitratorsMock) ProcessSpecialTxPayload ¶
func (a *ArbitratorsMock) ProcessSpecialTxPayload(p types.Payload, height uint32) error
func (*ArbitratorsMock) RecoverFromCheckPoints ¶ added in v0.3.2
func (a *ArbitratorsMock) RecoverFromCheckPoints(height uint32) (uint32, error)
func (*ArbitratorsMock) SetArbitrators ¶
func (a *ArbitratorsMock) SetArbitrators(ar []ArbiterMember)
func (*ArbitratorsMock) SetCandidates ¶
func (a *ArbitratorsMock) SetCandidates(ca []ArbiterMember)
func (*ArbitratorsMock) SetDutyChangeCount ¶
func (a *ArbitratorsMock) SetDutyChangeCount(count int)
func (*ArbitratorsMock) SetDutyChangedCount ¶
func (a *ArbitratorsMock) SetDutyChangedCount(count int)
func (*ArbitratorsMock) SetNeedRevertToDPOSTX ¶ added in v0.7.0
func (a *ArbitratorsMock) SetNeedRevertToDPOSTX(need bool)
func (*ArbitratorsMock) SetNextArbitrators ¶
func (a *ArbitratorsMock) SetNextArbitrators(ar []ArbiterMember)
func (*ArbitratorsMock) SetNextCandidates ¶
func (a *ArbitratorsMock) SetNextCandidates(ca []ArbiterMember)
func (*ArbitratorsMock) Start ¶ added in v0.3.2
func (a *ArbitratorsMock) Start()
type ChangeType ¶
type ChangeType byte
type CheckPoint ¶ added in v0.3.2
type CheckPoint struct { StateKeyFrame Height uint32 DutyIndex int CurrentArbitrators []ArbiterMember NextArbitrators []ArbiterMember NextCandidates []ArbiterMember CurrentCandidates []ArbiterMember CurrentReward RewardData NextReward RewardData CurrentCRCArbitersMap map[common.Uint168]ArbiterMember NextCRCArbitersMap map[common.Uint168]ArbiterMember NextCRCArbiters []ArbiterMember // contains filtered or unexported fields }
CheckPoint defines all variables need record in database
func NewCheckpoint ¶ added in v0.5.0
func NewCheckpoint(ar *arbitrators) *CheckPoint
func (*CheckPoint) DataExtension ¶ added in v0.5.0
func (c *CheckPoint) DataExtension() string
func (*CheckPoint) Deserialize ¶ added in v0.5.0
func (c *CheckPoint) Deserialize(r io.Reader) (err error)
Deserialize read data to reader
func (*CheckPoint) EffectivePeriod ¶ added in v0.5.0
func (c *CheckPoint) EffectivePeriod() uint32
func (*CheckPoint) Generator ¶ added in v0.5.0
func (c *CheckPoint) Generator() func(buf []byte) checkpoint.ICheckPoint
func (*CheckPoint) GetHeight ¶ added in v0.5.0
func (c *CheckPoint) GetHeight() uint32
func (*CheckPoint) Key ¶ added in v0.5.0
func (c *CheckPoint) Key() string
func (*CheckPoint) LogError ¶ added in v0.5.0
func (c *CheckPoint) LogError(err error)
func (*CheckPoint) OnBlockSaved ¶ added in v0.5.0
func (c *CheckPoint) OnBlockSaved(block *types.DposBlock)
func (*CheckPoint) OnInit ¶ added in v0.5.0
func (c *CheckPoint) OnInit()
func (*CheckPoint) OnRollbackSeekTo ¶ added in v0.8.0
func (c *CheckPoint) OnRollbackSeekTo(height uint32)
func (*CheckPoint) OnRollbackTo ¶ added in v0.5.0
func (c *CheckPoint) OnRollbackTo(height uint32) error
func (*CheckPoint) Priority ¶ added in v0.5.0
func (c *CheckPoint) Priority() checkpoint.Priority
func (*CheckPoint) SavePeriod ¶ added in v0.5.0
func (c *CheckPoint) SavePeriod() uint32
func (*CheckPoint) Serialize ¶ added in v0.5.0
func (c *CheckPoint) Serialize(w io.Writer) (err error)
Serialize write data to writer
func (*CheckPoint) SetHeight ¶ added in v0.5.0
func (c *CheckPoint) SetHeight(height uint32)
func (*CheckPoint) Snapshot ¶ added in v0.5.0
func (c *CheckPoint) Snapshot() checkpoint.ICheckPoint
func (*CheckPoint) StartHeight ¶ added in v0.5.0
func (c *CheckPoint) StartHeight() uint32
type ConsesusAlgorithm ¶ added in v0.7.0
type ConsesusAlgorithm byte
const ( DPOS ConsesusAlgorithm = 0x00 POW ConsesusAlgorithm = 0x01 )
type IArbitratorsRecord ¶ added in v0.3.2
type IArbitratorsRecord interface { GetHeightsDesc() ([]uint32, error) GetCheckPoint(height uint32) (*CheckPoint, error) SaveArbitersState(point *CheckPoint) error }
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
Producer holds a producer's info. It provides read only methods to access producer's info.
func (*Producer) ActivateRequestHeight ¶ added in v0.3.2
func (*Producer) AvailableAmount ¶ added in v0.7.0
func (*Producer) CancelHeight ¶
CancelHeight returns the height when the producer was canceled.
func (*Producer) DepositAmount ¶ added in v0.5.0
func (*Producer) Deserialize ¶ added in v0.3.2
func (*Producer) IllegalHeight ¶
func (*Producer) InactiveSince ¶
func (*Producer) Info ¶
func (p *Producer) Info() payload.ProducerInfo
Info returns a copy of the origin registered producer info.
func (*Producer) NodePublicKey ¶
func (*Producer) OwnerPublicKey ¶
func (*Producer) RegisterHeight ¶
RegisterHeight returns the height when the producer was registered.
func (*Producer) State ¶
func (p *Producer) State() ProducerState
State returns the producer's state, can be pending, active or canceled.
func (*Producer) TotalAmount ¶ added in v0.7.0
type ProducerState ¶
type ProducerState byte
ProducerState represents the state of a producer.
const ( // Pending indicates the producer is just registered and didn't get 6 // confirmations yet. Pending ProducerState = iota // Active indicates the producer is registered and confirmed by more than // 6 blocks. Active // Inactive indicates the producer has been inactivated for a period which shall // be punished and will be activated later. Inactive // Canceled indicates the producer was canceled. Canceled // Illegal indicates the producer was found to break the consensus. Illegal // Returned indicates the producer has canceled and deposit returned. Returned )
func (ProducerState) String ¶
func (ps ProducerState) String() string
type RewardData ¶ added in v0.3.2
type RewardData struct { OwnerVotesInRound map[common.Uint168]common.Fixed64 TotalVotesInRound common.Fixed64 }
RewardData defines variables to calculate reward of a round
func NewRewardData ¶ added in v0.3.2
func NewRewardData() *RewardData
func (*RewardData) Deserialize ¶ added in v0.3.2
func (d *RewardData) Deserialize(r io.Reader) (err error)
type State ¶
type State struct { *StateKeyFrame // contains filtered or unexported fields }
State is a memory database storing DPOS producers state, like pending producers active producers and their votes.
func NewState ¶
func NewState(chainParams *config.Params, getArbiters func() []*ArbiterInfo, getCRMembers func() []*state.CRMember, isInElectionPeriod func() bool, getProducerDepositAmount func(common.Uint168) (common.Fixed64, error), tryUpdateCRMemberInactivity func(did common.Uint168, needReset bool, height uint32), tryRevertCRMemberInactivityfunc func(did common.Uint168, oriState state.MemberState, oriInactiveCount uint32, height uint32), tryUpdateCRMemberIllegal func(did common.Uint168, height uint32), tryRevertCRMemberIllegal func(did common.Uint168, oriState state.MemberState, height uint32)) *State
NewState returns a new State instance.
func (*State) ExistProducerByDepositHash ¶ added in v0.5.0
func (*State) GetActiveProducers ¶
GetActiveProducers returns all producers that in active state.
func (*State) GetAllProducers ¶ added in v0.3.2
GetAllProducers returns all producers including pending, active, canceled, illegal and inactive producers.
func (*State) GetAllProducersPublicKey ¶ added in v0.7.0
func (*State) GetCanceledProducers ¶
GetCanceledProducers returns all producers that in cancel state.
func (*State) GetConsensusAlgorithm ¶ added in v0.7.0
func (s *State) GetConsensusAlgorithm() ConsesusAlgorithm
func (*State) GetHistory ¶
func (s *State) GetHistory(height uint32) (*StateKeyFrame, error)
GetHistory returns a history state instance storing the producers and votes on the historical height.
func (*State) GetIllegalProducers ¶
GetIllegalProducers returns all illegal producers.
func (*State) GetInactiveProducers ¶
GetIllegalProducers returns all inactive producers.
func (*State) GetLastIrreversibleHeight ¶ added in v0.7.0
func (*State) GetPendingCanceledProducers ¶ added in v0.3.2
GetPendingCanceledProducers returns all producers that in pending canceled state.
func (*State) GetPendingProducers ¶
GetPendingProducers returns all producers that in pending state.
func (*State) GetProducer ¶
GetProducer returns a producer with the producer's node public key or it's owner public key including canceled and illegal producers. If no matches return nil.
func (*State) GetProducers ¶
GetProducers returns all producers including pending and active producers (no canceled and illegal producers).
func (*State) GetReturnedDepositProducers ¶ added in v0.3.2
GetReturnedDepositProducers returns producers that in returned deposit state.
func (*State) GetVotedProducers ¶ added in v0.3.2
GetVotedProducers returns all producers that in active state with votes.
func (*State) IsAbleToRecoverFromInactiveMode ¶ added in v0.3.2
IsAbleToRecoverFromInactiveMode returns if most of the emergency arbiters have activated and able to work again
func (*State) IsAbleToRecoverFromUnderstaffedState ¶ added in v0.3.2
IsAbleToRecoverFromInactiveMode returns if there are enough active arbiters
func (*State) IsActiveProducer ¶
IsActiveProducer returns if a producer is in activate list according to the public key.
func (*State) IsCanceledProducer ¶
IsCanceledProducer returns if a producer is in canceled list according to the public key.
func (*State) IsDPOSTransaction ¶
func (s *State) IsDPOSTransaction(tx *types.Transaction) bool
IsDPOSTransaction returns if a transaction will change the producers and votes state.
func (*State) IsIllegalProducer ¶
IsIllegalProducer returns if a producer is in illegal list according to the public key.
func (*State) IsInactiveProducer ¶
IsInactiveProducer returns if a producer is in inactivate list according to the public key.
func (*State) IsIrreversible ¶ added in v0.7.0
is this Height Irreversible
func (*State) IsPendingProducer ¶
IsPendingProducer returns if a producer is in pending list according to the public key.
func (*State) LeaveEmergency ¶ added in v0.3.2
LeaveEmergency will reset EmergencyInactiveArbiters variable
func (*State) NicknameExists ¶
NicknameExists returns if a nickname is exists.
func (*State) ProcessBlock ¶
ProcessBlock takes a block and it's confirm to update producers state and votes accordingly.
func (*State) ProcessSpecialTxPayload ¶
ProcessIllegalBlockEvidence takes a illegal block payload and change the producers state immediately. This is a spacial case that can be handled before it packed into a block.
func (*State) ProcessVoteStatisticsBlock ¶ added in v0.3.9
ProcessVoteStatisticsBlock deal with block with vote statistics error.
func (*State) ProducerExists ¶
ProducerExists returns if a producer is exists by it's node public key or owner public key.
func (*State) ProducerNodePublicKeyExists ¶ added in v0.3.2
ProducerExists returns if a producer is exists by it's node public key.
func (*State) ProducerOwnerPublicKeyExists ¶ added in v0.3.2
ProducerExists returns if a producer is exists by it's owner public key.
func (*State) RemoveSpecialTx ¶ added in v0.7.0
removeSpecialTx record hash of a special tx
func (*State) RollbackSeekTo ¶ added in v0.8.0
OnRollbackSeekTo restores the database state to the given height.
func (*State) RollbackTo ¶
RollbackTo restores the database state to the given height, if no enough history to rollback to return error.
func (*State) SpecialTxExists ¶
func (s *State) SpecialTxExists(tx *types.Transaction) bool
SpecialTxExists returns if a special tx (typically means illegal and inactive tx) is exists by it's hash
type StateKeyFrame ¶ added in v0.3.2
type StateKeyFrame struct { NodeOwnerKeys map[string]string // NodePublicKey as key, OwnerPublicKey as value PendingProducers map[string]*Producer ActivityProducers map[string]*Producer InactiveProducers map[string]*Producer CanceledProducers map[string]*Producer IllegalProducers map[string]*Producer PendingCanceledProducers map[string]*Producer Votes map[string]struct{} DepositOutputs map[string]common.Fixed64 Nicknames map[string]struct{} SpecialTxHashes map[common.Uint256]struct{} PreBlockArbiters map[string]struct{} ProducerDepositMap map[common.Uint168]struct{} EmergencyInactiveArbiters map[string]struct{} LastRandomCandidateOwner string VersionStartHeight uint32 VersionEndHeight uint32 LastRandomCandidateHeight uint32 DPOSWorkHeight uint32 ConsensusAlgorithm ConsesusAlgorithm LastBlockTimestamp uint32 NeedRevertToDPOSTX bool NeedNextTurnDPOSInfo bool NoProducers bool NoClaimDPOSNode bool //this height we receieved reverttopow tx and also it is pow work height RevertToPOWBlockHeight uint32 //last irreversible height LastIrreversibleHeight uint32 //record the height our consensus chang from pow into dpos. //when it is dpos and before RevertToPOWStartHeight DPOSStartHeight is height - IrreversibleHeight DPOSStartHeight uint32 }
StateKeyFrame holds necessary state about State
func NewStateKeyFrame ¶ added in v0.5.0
func NewStateKeyFrame() *StateKeyFrame
func (*StateKeyFrame) Deserialize ¶ added in v0.3.2
func (s *StateKeyFrame) Deserialize(r io.Reader) (err error)
func (*StateKeyFrame) DeserializeDIDSet ¶ added in v0.5.0
func (*StateKeyFrame) DeserializeFixed64Map ¶ added in v0.5.0
func (*StateKeyFrame) DeserializeHashSet ¶ added in v0.3.2
func (*StateKeyFrame) DeserializeProducerMap ¶ added in v0.3.2
func (*StateKeyFrame) DeserializeStringMap ¶ added in v0.3.2
func (*StateKeyFrame) DeserializeStringSet ¶ added in v0.3.2
func (s *StateKeyFrame) DeserializeStringSet( r io.Reader) (vmap map[string]struct{}, err error)
func (*StateKeyFrame) Serialize ¶ added in v0.3.2
func (s *StateKeyFrame) Serialize(w io.Writer) (err error)
func (*StateKeyFrame) SerializeDIDSet ¶ added in v0.5.0
func (*StateKeyFrame) SerializeFixed64Map ¶ added in v0.5.0
func (*StateKeyFrame) SerializeHashSet ¶ added in v0.3.2
func (*StateKeyFrame) SerializeProducerMap ¶ added in v0.3.2
func (*StateKeyFrame) SerializeStringMap ¶ added in v0.3.2
func (*StateKeyFrame) SerializeStringSet ¶ added in v0.3.2
func (s *StateKeyFrame) SerializeStringSet(vmap map[string]struct{}, w io.Writer) (err error)