Documentation ¶
Index ¶
- func DisableLog()
- func NewArbitrators(chainParams *config.Params, bestHeight func() uint32) (*arbitrators, error)
- func UseLogger(logger elalog.Logger)
- type Arbitrators
- type ArbitratorsMock
- func (a *ArbitratorsMock) DumpInfo()
- func (a *ArbitratorsMock) GetArbitersCount() int
- func (a *ArbitratorsMock) GetArbitersMajorityCount() int
- func (a *ArbitratorsMock) GetArbitrators() [][]byte
- func (a *ArbitratorsMock) GetCRCArbitrators() map[string]*Producer
- func (a *ArbitratorsMock) GetCRCProducer(publicKey []byte) *Producer
- func (a *ArbitratorsMock) GetCandidateOwnerProgramHashes() []*common.Uint168
- func (a *ArbitratorsMock) GetCandidates() [][]byte
- func (a *ArbitratorsMock) GetCurrentOwnerProgramHashes() []*common.Uint168
- func (a *ArbitratorsMock) GetDutyChangeCount() int
- func (a *ArbitratorsMock) GetDutyChangedCount() int
- func (a *ArbitratorsMock) GetDutyIndex() int
- func (a *ArbitratorsMock) GetDutyIndexByHeight(height uint32) int
- func (a *ArbitratorsMock) GetLastConfirmedBlockTimeStamp() uint32
- func (a *ArbitratorsMock) GetNeedConnectArbiters(height uint32) map[string]*p2p.PeerAddr
- func (a *ArbitratorsMock) GetNextArbitrators() [][]byte
- func (a *ArbitratorsMock) GetNextCandidates() [][]byte
- func (a *ArbitratorsMock) GetNextOnDutyArbitrator(offset uint32) []byte
- func (a *ArbitratorsMock) GetNormalArbitrators() ([][]byte, error)
- func (a *ArbitratorsMock) GetOnDutyArbitrator() []byte
- func (a *ArbitratorsMock) GetOwnerVotes(programHash *common.Uint168) common.Fixed64
- func (a *ArbitratorsMock) GetTotalVotesInRound() common.Fixed64
- func (a *ArbitratorsMock) HasArbitersMajorityCount(num int) bool
- func (a *ArbitratorsMock) HasArbitersMinorityCount(num int) bool
- func (a *ArbitratorsMock) IsArbitrator(pk []byte) bool
- func (a *ArbitratorsMock) IsCRCArbitrator(pk []byte) bool
- func (a *ArbitratorsMock) IsCRCArbitratorNodePublicKey(nodePublicKeyHex string) bool
- func (a *ArbitratorsMock) IsCRCArbitratorProgramHash(hash *common.Uint168) bool
- func (a *ArbitratorsMock) ProcessBlock(block *types.Block, confirm *payload.Confirm)
- func (a *ArbitratorsMock) ProcessSpecialTxPayload(p types.Payload, height uint32) error
- func (a *ArbitratorsMock) RollbackTo(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) TryEnterEmergency(blockTime uint32) bool
- type ChangeType
- type Producer
- func (p *Producer) CancelHeight() uint32
- 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) State() ProducerState
- func (p *Producer) Votes() common.Fixed64
- type ProducerState
- type State
- func (s *State) GetActiveProducers() []*Producer
- func (s *State) GetCanceledProducers() []*Producer
- func (s *State) GetHistory(height uint32) (*State, error)
- func (s *State) GetIllegalProducers() []*Producer
- func (s *State) GetInactiveProducers() []*Producer
- func (s *State) GetPendingProducers() []*Producer
- func (s *State) GetProducer(publicKey []byte) *Producer
- func (s *State) GetProducers() []*Producer
- func (s *State) GetSnapshot(height uint32) *State
- 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) NicknameExists(nickname string) bool
- func (s *State) ProcessBlock(block *types.Block, confirm *payload.Confirm)
- func (s *State) ProcessSpecialTxPayload(p types.Payload)
- func (s *State) ProducerExists(publicKey []byte) bool
- func (s *State) RollbackTo(height uint32) error
- func (s *State) SpecialTxExists(hash *common.Uint256) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 { 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(height uint32) map[string]*p2p.PeerAddr GetDutyIndexByHeight(height uint32) int GetDutyIndex() int GetCRCProducer(publicKey []byte) *Producer GetCRCArbitrators() map[string]*Producer IsCRCArbitrator(pk []byte) bool IsCRCArbitratorProgramHash(hash *common.Uint168) bool IsCRCArbitratorNodePublicKey(nodePublicKeyHex string) bool GetCurrentOwnerProgramHashes() []*common.Uint168 GetCandidateOwnerProgramHashes() []*common.Uint168 GetOwnerVotes(programHash *common.Uint168) common.Fixed64 GetTotalVotesInRound() common.Fixed64 GetOnDutyArbitrator() []byte GetNextOnDutyArbitrator(offset uint32) []byte GetArbitersCount() int GetArbitersMajorityCount() int HasArbitersMajorityCount(num int) bool HasArbitersMinorityCount(num int) bool DumpInfo() }
type ArbitratorsMock ¶
type ArbitratorsMock struct { CurrentArbitrators [][]byte CurrentCandidates [][]byte NextArbitrators [][]byte NextCandidates [][]byte CurrentOwnerProgramHashes []*common.Uint168 CandidateOwnerProgramHashes []*common.Uint168 OwnerVotesInRound map[common.Uint168]common.Fixed64 TotalVotesInRound common.Fixed64 DutyChangedCount int MajorityCount int }
mock object of arbitrators
func NewArbitratorsMock ¶
func NewArbitratorsMock(arbitersByte [][]byte, changeCount, majorityCount int) *ArbitratorsMock
func (*ArbitratorsMock) DumpInfo ¶
func (a *ArbitratorsMock) DumpInfo()
func (*ArbitratorsMock) GetArbitersCount ¶
func (a *ArbitratorsMock) GetArbitersCount() int
func (*ArbitratorsMock) GetArbitersMajorityCount ¶
func (a *ArbitratorsMock) GetArbitersMajorityCount() int
func (*ArbitratorsMock) GetArbitrators ¶
func (a *ArbitratorsMock) GetArbitrators() [][]byte
func (*ArbitratorsMock) GetCRCArbitrators ¶
func (a *ArbitratorsMock) GetCRCArbitrators() map[string]*Producer
func (*ArbitratorsMock) GetCRCProducer ¶
func (a *ArbitratorsMock) GetCRCProducer(publicKey []byte) *Producer
func (*ArbitratorsMock) GetCandidateOwnerProgramHashes ¶
func (a *ArbitratorsMock) GetCandidateOwnerProgramHashes() []*common.Uint168
func (*ArbitratorsMock) GetCandidates ¶
func (a *ArbitratorsMock) GetCandidates() [][]byte
func (*ArbitratorsMock) GetCurrentOwnerProgramHashes ¶
func (a *ArbitratorsMock) GetCurrentOwnerProgramHashes() []*common.Uint168
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(height uint32) int
func (*ArbitratorsMock) GetLastConfirmedBlockTimeStamp ¶
func (a *ArbitratorsMock) GetLastConfirmedBlockTimeStamp() uint32
func (*ArbitratorsMock) GetNeedConnectArbiters ¶
func (a *ArbitratorsMock) GetNeedConnectArbiters(height uint32) map[string]*p2p.PeerAddr
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) GetNormalArbitrators ¶
func (a *ArbitratorsMock) GetNormalArbitrators() ([][]byte, error)
func (*ArbitratorsMock) GetOnDutyArbitrator ¶
func (a *ArbitratorsMock) GetOnDutyArbitrator() []byte
func (*ArbitratorsMock) GetOwnerVotes ¶
func (a *ArbitratorsMock) GetOwnerVotes(programHash *common.Uint168) common.Fixed64
func (*ArbitratorsMock) GetTotalVotesInRound ¶
func (a *ArbitratorsMock) GetTotalVotesInRound() common.Fixed64
func (*ArbitratorsMock) HasArbitersMajorityCount ¶
func (a *ArbitratorsMock) HasArbitersMajorityCount(num int) bool
func (*ArbitratorsMock) HasArbitersMinorityCount ¶
func (a *ArbitratorsMock) HasArbitersMinorityCount(num int) bool
func (*ArbitratorsMock) IsArbitrator ¶
func (a *ArbitratorsMock) IsArbitrator(pk []byte) bool
func (*ArbitratorsMock) IsCRCArbitrator ¶
func (a *ArbitratorsMock) IsCRCArbitrator(pk []byte) bool
func (*ArbitratorsMock) IsCRCArbitratorNodePublicKey ¶
func (a *ArbitratorsMock) IsCRCArbitratorNodePublicKey(nodePublicKeyHex string) bool
func (*ArbitratorsMock) IsCRCArbitratorProgramHash ¶
func (a *ArbitratorsMock) IsCRCArbitratorProgramHash(hash *common.Uint168) 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) RollbackTo ¶
func (a *ArbitratorsMock) RollbackTo(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) TryEnterEmergency ¶
func (a *ArbitratorsMock) TryEnterEmergency(blockTime uint32) bool
type ChangeType ¶
type ChangeType byte
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) CancelHeight ¶
CancelHeight returns the height when the producer was canceled.
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 // Activate indicates the producer is registered and confirmed by more than // 6 blocks. Activate // Inactivate indicates the producer has been inactive for a period which shall // be punished and will be activate later Inactivate // Canceled indicates the producer was canceled. Canceled // FoundBad indicates the producer was found doing bad. FoundBad // ReturnedDeposit indicates the producer has canceled and returned deposit ReturnedDeposit )
func (ProducerState) String ¶
func (ps ProducerState) String() string
type State ¶
type State struct {
// 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) GetCanceledProducers ¶
GetCanceledProducers returns all producers that in cancel state.
func (*State) GetHistory ¶
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) 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) GetSnapshot ¶
GetSnapshot returns a snapshot of the state according to the given height.
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) 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) ProducerExists ¶
ProducerExists returns if a producer is exists by it's node public key or owner public key.
func (*State) RollbackTo ¶
RollbackTo restores the database state to the given height, if no enough history to rollback to return error.