Documentation ¶
Index ¶
- Constants
- Variables
- func DisableLog()
- func NewArbitrators(chainParams *config.Params, store IArbitratorsRecord, bestHeight func() uint32, ...) (*arbitrators, error)
- func UseLogger(logger elalog.Logger)
- type Arbitrators
- type ArbitratorsMock
- func (a *ArbitratorsMock) CheckDPOSIllegalTx(block *types.Block) error
- func (a *ArbitratorsMock) DumpInfo(height uint32)
- func (a *ArbitratorsMock) GetArbitersCount() int
- func (a *ArbitratorsMock) GetArbitersMajorityCount() int
- func (a *ArbitratorsMock) GetArbitersRoundReward() map[common.Uint168]common.Fixed64
- func (a *ArbitratorsMock) GetArbitrators() [][]byte
- func (a *ArbitratorsMock) GetCRCArbiters() [][]byte
- func (a *ArbitratorsMock) GetCRCArbitersCount() int
- func (a *ArbitratorsMock) GetCRCArbitrators() map[string]*Producer
- func (a *ArbitratorsMock) GetCRCProducer(publicKey []byte) *Producer
- func (a *ArbitratorsMock) GetCandidates() [][]byte
- func (a *ArbitratorsMock) GetCrossChainArbiters() [][]byte
- 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) GetLastConfirmedBlockTimeStamp() uint32
- func (a *ArbitratorsMock) GetNeedConnectArbiters() []peer.PID
- func (a *ArbitratorsMock) GetNextArbitrators() [][]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) GetSnapshot(height uint32) []*KeyFrame
- 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) IsInactiveMode() bool
- func (a *ArbitratorsMock) IsUnderstaffedMode() bool
- func (a *ArbitratorsMock) ProcessBlock(block *types.Block, confirm *payload.Confirm)
- func (a *ArbitratorsMock) ProcessSpecialTxPayload(p types.Payload, height uint32) error
- func (a *ArbitratorsMock) RecoverFromCheckPoints(height uint32) (uint32, error)
- func (a *ArbitratorsMock) RollbackTo(height uint32) error
- func (a *ArbitratorsMock) SaveCheckPoint(height uint32) error
- func (a *ArbitratorsMock) SetArbitrators(ar [][]byte)
- func (a *ArbitratorsMock) SetCandidates(ca [][]byte)
- func (a *ArbitratorsMock) SetDutyChangeCount(count int)
- func (a *ArbitratorsMock) SetDutyChangedCount(count int)
- func (a *ArbitratorsMock) SetNextArbitrators(ar [][]byte)
- func (a *ArbitratorsMock) SetNextCandidates(ca [][]byte)
- func (a *ArbitratorsMock) Start()
- func (a *ArbitratorsMock) TryEnterEmergency(blockTime uint32) bool
- type ChangeType
- type CheckPoint
- type IArbitratorsRecord
- type KeyFrame
- type Producer
- func (p *Producer) ActivateRequestHeight() uint32
- func (p *Producer) CancelHeight() uint32
- 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) Votes() common.Fixed64
- type ProducerState
- type RewardData
- type State
- func (s *State) GetActiveProducers() []*Producer
- func (s *State) GetAllProducers() []*Producer
- func (s *State) GetCanceledProducers() []*Producer
- func (s *State) GetHistory(height uint32) (*StateKeyFrame, error)
- func (s *State) GetIllegalProducers() []*Producer
- func (s *State) GetInactiveProducers() []*Producer
- 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) IsPendingProducer(publicKey []byte) bool
- func (s *State) LeaveEmergency()
- 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) 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) 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) DeserializeVotesMap(r io.Reader) (vmap map[string]*types.Output, err error)
- func (s *StateKeyFrame) Serialize(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)
- func (s *StateKeyFrame) SerializeVotesMap(vmap map[string]*types.Output, 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 // 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.
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 ¶
Types ¶
type Arbitrators ¶
type Arbitrators interface { Start() RecoverFromCheckPoints(height uint32) (uint32, error) CheckDPOSIllegalTx(block *types.Block) error ProcessBlock(block *types.Block, confirm *payload.Confirm) ProcessSpecialTxPayload(p types.Payload, height uint32) error RollbackTo(height uint32) error IsArbitrator(pk []byte) bool GetArbitrators() [][]byte GetCandidates() [][]byte GetNextArbitrators() [][]byte GetNextCandidates() [][]byte GetNeedConnectArbiters() []peer.PID GetDutyIndexByHeight(height uint32) int GetDutyIndex() int GetCurrentRewardData() RewardData GetNextRewardData() RewardData GetArbitersRoundReward() map[common.Uint168]common.Fixed64 GetFinalRoundChange() common.Fixed64 IsInactiveMode() bool IsUnderstaffedMode() bool GetCRCArbiters() [][]byte GetCRCProducer(publicKey []byte) *Producer GetCRCArbitrators() map[string]*Producer IsCRCArbitrator(pk []byte) bool IsActiveProducer(pk []byte) bool IsDisabledProducer(pk []byte) bool GetOnDutyArbitrator() []byte GetNextOnDutyArbitrator(offset uint32) []byte GetOnDutyCrossChainArbitrator() []byte GetCrossChainArbiters() [][]byte GetCrossChainArbitersCount() int GetCrossChainArbitersMajorityCount() int GetArbitersCount() int GetCRCArbitersCount() int GetArbitersMajorityCount() int HasArbitersMajorityCount(num int) bool HasArbitersMinorityCount(num int) bool GetSnapshot(height uint32) []*KeyFrame DumpInfo(height uint32) }
type ArbitratorsMock ¶
type ArbitratorsMock struct { CurrentArbitrators [][]byte CRCArbitrators [][]byte CurrentCandidates [][]byte NextArbitrators [][]byte NextCandidates [][]byte 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 InactiveMode bool ActiveProducer [][]byte Snapshot []*KeyFrame CurrentReward RewardData NextReward RewardData }
mock object of arbitrators
func NewArbitratorsMock ¶
func NewArbitratorsMock(arbitersByte [][]byte, changeCount, majorityCount int) *ArbitratorsMock
func (*ArbitratorsMock) CheckDPOSIllegalTx ¶ added in v0.3.2
func (a *ArbitratorsMock) CheckDPOSIllegalTx(block *types.Block) error
func (*ArbitratorsMock) DumpInfo ¶
func (a *ArbitratorsMock) DumpInfo(height uint32)
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() [][]byte
func (*ArbitratorsMock) GetCRCArbiters ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCRCArbiters() [][]byte
func (*ArbitratorsMock) GetCRCArbitersCount ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCRCArbitersCount() int
func (*ArbitratorsMock) GetCRCArbitrators ¶
func (a *ArbitratorsMock) GetCRCArbitrators() map[string]*Producer
func (*ArbitratorsMock) GetCRCProducer ¶
func (a *ArbitratorsMock) GetCRCProducer(publicKey []byte) *Producer
func (*ArbitratorsMock) GetCandidates ¶
func (a *ArbitratorsMock) GetCandidates() [][]byte
func (*ArbitratorsMock) GetCrossChainArbiters ¶ added in v0.3.2
func (a *ArbitratorsMock) GetCrossChainArbiters() [][]byte
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) GetLastConfirmedBlockTimeStamp ¶
func (a *ArbitratorsMock) GetLastConfirmedBlockTimeStamp() uint32
func (*ArbitratorsMock) GetNeedConnectArbiters ¶
func (a *ArbitratorsMock) GetNeedConnectArbiters() []peer.PID
func (*ArbitratorsMock) GetNextArbitrators ¶
func (a *ArbitratorsMock) GetNextArbitrators() [][]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) GetSnapshot ¶ added in v0.3.2
func (a *ArbitratorsMock) GetSnapshot(height uint32) []*KeyFrame
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) IsInactiveMode ¶ added in v0.3.2
func (a *ArbitratorsMock) IsInactiveMode() bool
func (*ArbitratorsMock) IsUnderstaffedMode ¶ added in v0.3.2
func (a *ArbitratorsMock) IsUnderstaffedMode() bool
func (*ArbitratorsMock) ProcessBlock ¶
func (a *ArbitratorsMock) ProcessBlock(block *types.Block, confirm *payload.Confirm)
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) RollbackTo ¶
func (a *ArbitratorsMock) RollbackTo(height uint32) error
func (*ArbitratorsMock) SaveCheckPoint ¶ added in v0.3.2
func (a *ArbitratorsMock) SaveCheckPoint(height uint32) error
func (*ArbitratorsMock) SetArbitrators ¶
func (a *ArbitratorsMock) SetArbitrators(ar [][]byte)
func (*ArbitratorsMock) SetCandidates ¶
func (a *ArbitratorsMock) SetCandidates(ca [][]byte)
func (*ArbitratorsMock) SetDutyChangeCount ¶
func (a *ArbitratorsMock) SetDutyChangeCount(count int)
func (*ArbitratorsMock) SetDutyChangedCount ¶
func (a *ArbitratorsMock) SetDutyChangedCount(count int)
func (*ArbitratorsMock) SetNextArbitrators ¶
func (a *ArbitratorsMock) SetNextArbitrators(ar [][]byte)
func (*ArbitratorsMock) SetNextCandidates ¶
func (a *ArbitratorsMock) SetNextCandidates(ca [][]byte)
func (*ArbitratorsMock) Start ¶ added in v0.3.2
func (a *ArbitratorsMock) Start()
func (*ArbitratorsMock) TryEnterEmergency ¶
func (a *ArbitratorsMock) TryEnterEmergency(blockTime uint32) bool
type ChangeType ¶
type ChangeType byte
type CheckPoint ¶ added in v0.3.2
type CheckPoint struct { KeyFrame StateKeyFrame Height uint32 DutyIndex int NextArbitrators [][]byte NextCandidates [][]byte CurrentCandidates [][]byte CurrentReward RewardData NextReward RewardData // contains filtered or unexported fields }
CheckPoint defines all variables need record in database
type IArbitratorsRecord ¶ added in v0.3.2
type IArbitratorsRecord interface { GetHeightsDesc() ([]uint32, error) GetCheckPoint(height uint32) (*CheckPoint, error) SaveArbitersState(point *CheckPoint) error }
type KeyFrame ¶ added in v0.3.2
type KeyFrame struct {
CurrentArbitrators [][]byte
}
KeyFrame holds necessary state about arbitrators
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) CancelHeight ¶
CancelHeight returns the height when the producer was canceled.
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.
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 { OwnerProgramHashes []*common.Uint168 CandidateOwnerProgramHashes []*common.Uint168 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 (*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) GetCanceledProducers ¶
GetCanceledProducers returns all producers that in cancel state.
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 ¶
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) IsPendingProducer ¶
IsPendingProducer returns if a producer is in pending list according to the public key.
func (*State) LeaveEmergency ¶ added in v0.3.2
func (s *State) LeaveEmergency()
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) 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]*types.Output Nicknames map[string]struct{} SpecialTxHashes map[common.Uint256]struct{} PreBlockArbiters map[string]struct{} EmergencyInactiveArbiters map[string]struct{} VersionStartHeight uint32 VersionEndHeight uint32 }
StateKeyFrame holds necessary state about State
func (*StateKeyFrame) Deserialize ¶ added in v0.3.2
func (s *StateKeyFrame) Deserialize(r io.Reader) (err error)
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) DeserializeVotesMap ¶ added in v0.3.2
func (*StateKeyFrame) Serialize ¶ added in v0.3.2
func (s *StateKeyFrame) Serialize(w io.Writer) (err error)
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)