Documentation ¶
Overview ¶
Package dpos Uses nacl's secret_box to encrypt a net.Conn. It is (meant to be) an implementation of the STS protocol. Note we do not (yet) assume that a remote peer's pubkey is known ahead of time, and thus we are technically still vulnerable to MITM. (TODO!) See docs/sts-final.pdf for more info
Index ¶
- Constants
- Variables
- func GenAddressByPubKey(pubkey crypto.PubKey) []byte
- func New(cfg *types.Consensus, sub []byte) queue.Module
- func Parallel(tasks ...func())
- type Client
- func (client *Client) CheckBlock(parent *types.Block, current *types.BlockDetail) error
- func (client *Client) CheckTxDup(txs []*types.Transaction, height int64) (transactions []*types.Transaction)
- func (client *Client) Close()
- func (client *Client) CmpBestBlock(newBlock *types.Block, cmpBlock *types.Block) bool
- func (client *Client) CreateBlock()
- func (client *Client) CreateGenesisTx() (ret []*types.Transaction)
- func (client *Client) CreateRecordCBTx(info *dty.DposCBInfo) (tx *types.Transaction, err error)
- func (client *Client) CreateRegVrfMTx(info *dty.DposVrfMRegist) (tx *types.Transaction, err error)
- func (client *Client) CreateRegVrfRPTx(info *dty.DposVrfRPRegist) (tx *types.Transaction, err error)
- func (client *Client) CreateTopNRegistTx(reg *dty.TopNCandidatorRegist) (tx *types.Transaction, err error)
- func (client *Client) GenesisDoc() *ttypes.GenesisDoc
- func (client *Client) GetConsensusState() *ConsensusState
- func (client *Client) GetGenesisBlockTime() int64
- func (client *Client) GetNode() *Node
- func (client *Client) PrivValidator() ttypes.PrivValidator
- func (client *Client) ProcEvent(msg *queue.Message) bool
- func (client *Client) QueryCandidators() ([]*dty.Candidator, error)
- func (client *Client) QueryTopNCandidators(version int64) (*dty.TopNCandidators, error)
- func (client *Client) QueryVrfInfos(pubkeys [][]byte, cycle int64) ([]*dty.VrfInfo, error)
- func (client *Client) SetBlockTime(blockTime int64)
- func (client *Client) SetQueueClient(q queue.Client)
- func (client *Client) SetTestFlag()
- func (client *Client) StartConsensus()
- func (client *Client) StopC() <-chan struct{}
- func (client *Client) ValidatorIndex() int
- type ConsensusState
- func (cs *ConsensusState) AddVotes(vote *dpostype.DPosVote)
- func (cs *ConsensusState) CacheNotify(notify *dpostype.DPosNotify)
- func (cs *ConsensusState) CacheVotes(vote *dpostype.DPosVote)
- func (cs *ConsensusState) CheckVotes() (ty int, vote *dpostype.VoteItem)
- func (cs *ConsensusState) ClearCachedNotify()
- func (cs *ConsensusState) ClearCachedVotes()
- func (cs *ConsensusState) ClearVotes()
- func (cs *ConsensusState) GetCBInfoByCircle(cycle int64) (info *dty.DposCBInfo)
- func (cs *ConsensusState) GetLastestTopNCandidators() (info *dty.TopNCandidators)
- func (cs *ConsensusState) GetPrivValidator() ttypes.PrivValidator
- func (cs *ConsensusState) GetTopNCandidatorsByVersion(version int64) (info *dty.TopNCandidators)
- func (cs *ConsensusState) GetValidatorMgr() ValidatorMgr
- func (cs *ConsensusState) GetValidators() []*ttypes.Validator
- func (cs *ConsensusState) GetVrfInfoByCircle(cycle int64, ty int) (info *dty.VrfInfo)
- func (cs *ConsensusState) GetVrfInfosByCircle(cycle int64) (infos []*dty.VrfInfo)
- func (cs *ConsensusState) Init()
- func (cs *ConsensusState) InitCycleBoundaryInfo(task Task)
- func (cs *ConsensusState) InitCycleVrfInfo(task Task)
- func (cs *ConsensusState) InitCycleVrfInfos(task Task)
- func (cs *ConsensusState) InitTopNCandidators(version int64)
- func (cs *ConsensusState) IsInTopN(info *dty.TopNCandidators) bool
- func (cs *ConsensusState) IsProposer() bool
- func (cs *ConsensusState) IsRunning() bool
- func (cs *ConsensusState) IsTopNRegisted(info *dty.TopNCandidators) bool
- func (cs *ConsensusState) QueryCycleBoundaryInfo(cycle int64) (*dty.DposCBInfo, error)
- func (cs *ConsensusState) QueryVrf(pubkey []byte, cycle int64) (info *dty.VrfInfo, err error)
- func (cs *ConsensusState) QueryVrfs(set *ttypes.ValidatorSet, cycle int64) (infos []*dty.VrfInfo, err error)
- func (cs *ConsensusState) SaveMyVote()
- func (cs *ConsensusState) SaveNotify()
- func (cs *ConsensusState) SaveVote()
- func (cs *ConsensusState) SendCBTx(info *dty.DposCBInfo) bool
- func (cs *ConsensusState) SendRegistVrfMTx(info *dty.DposVrfMRegist) bool
- func (cs *ConsensusState) SendRegistVrfRPTx(info *dty.DposVrfRPRegist) bool
- func (cs *ConsensusState) SendTopNRegistTx(reg *dty.TopNCandidatorRegist) bool
- func (cs *ConsensusState) SetBroadcastChannel(broadcastChannel chan<- MsgInfo)
- func (cs *ConsensusState) SetCurrentVote(vote *dpostype.VoteItem)
- func (cs *ConsensusState) SetMyVote(vote *dpostype.DPosVote)
- func (cs *ConsensusState) SetNotify(notify *dpostype.DPosNotify)
- func (cs *ConsensusState) SetOurID(id ID)
- func (cs *ConsensusState) SetPrivValidator(priv ttypes.PrivValidator, index int)
- func (cs *ConsensusState) SetState(state State)
- func (cs *ConsensusState) ShuffleValidators(cycle int64)
- func (cs *ConsensusState) Start()
- func (cs *ConsensusState) Stop()
- func (cs *ConsensusState) String() string
- func (cs *ConsensusState) UpdateCBInfo(info *dty.DposCBInfo)
- func (cs *ConsensusState) UpdateTopNCandidators(info *dty.TopNCandidators)
- func (cs *ConsensusState) UpdateVrfInfo(info *dty.VrfInfo)
- func (cs *ConsensusState) UpdateVrfInfos(cycle int64, infos []*dty.VrfInfo)
- func (cs *ConsensusState) VerifyCBInfo(info *dty.DposCBInfo) bool
- func (cs *ConsensusState) VerifyNotify(notify *dpostype.DPosNotify) bool
- func (cs *ConsensusState) VerifyVote(vote *dpostype.DPosVote) bool
- func (cs *ConsensusState) VrfEvaluate(input []byte) (hash [32]byte, proof []byte)
- func (cs *ConsensusState) VrfProof(pubkey []byte, input []byte, hash [32]byte, proof []byte) bool
- type ID
- type IP2IPPort
- type InitState
- type MsgInfo
- type Node
- func (node *Node) Broadcast(msg MsgInfo) chan bool
- func (node *Node) BroadcastRoutine()
- func (node *Node) CompatibleWith(other NodeInfo) error
- func (node *Node) DialPeerWithAddress(addr string) error
- func (node *Node) FilterConnByAddr(addr net.Addr) error
- func (node *Node) IsRunning() bool
- func (node *Node) Start(testFlag bool)
- func (node *Node) StartConsensusRoutine()
- func (node *Node) Stop()
- func (node *Node) StopPeerForError(peer Peer, reason interface{})
- type NodeInfo
- type Peer
- type PeerSet
- type SecretConnection
- func (sc *SecretConnection) Close() error
- func (sc *SecretConnection) LocalAddr() net.Addr
- func (sc *SecretConnection) Read(data []byte) (n int, err error)
- func (sc *SecretConnection) RemoteAddr() net.Addr
- func (sc *SecretConnection) RemotePubKey() crypto.PubKey
- func (sc *SecretConnection) SetDeadline(t time.Time) error
- func (sc *SecretConnection) SetReadDeadline(t time.Time) error
- func (sc *SecretConnection) SetWriteDeadline(t time.Time) error
- func (sc *SecretConnection) Write(data []byte) (n int, err error)
- type StackError
- type State
- type Task
- type TopNVersionInfo
- type ValidatorMgr
- func (s ValidatorMgr) Bytes() []byte
- func (s ValidatorMgr) Copy() ValidatorMgr
- func (s ValidatorMgr) Equals(s2 ValidatorMgr) bool
- func (s *ValidatorMgr) FillVoteItem(voteItem *ttypes.VoteItem)
- func (s *ValidatorMgr) GetIndexByPubKey(pubkey []byte) (index int)
- func (s *ValidatorMgr) GetValidatorByIndex(index int) (addr []byte, val *ttypes.Validator)
- func (s ValidatorMgr) GetValidators() (current *ttypes.ValidatorSet)
- func (s ValidatorMgr) IsEmpty() bool
- func (s *ValidatorMgr) UpdateFromVoteItem(voteItem *ttypes.VoteItem) bool
- type VotedState
- type VotingState
- type WaitNofifyState
Constants ¶
const ( //VrfQueryTypeM vrf query type 为查询M信息 VrfQueryTypeM = 0 //VrfQueryTypeRP vrf query type 为查询RP信息 VrfQueryTypeRP = 1 )
const ( //ShuffleTypeNoVrf shuffle type: NoVrf, use default address order ShuffleTypeNoVrf = iota //ShuffleTypeVrf shuffle type: Vrf ShuffleTypeVrf //ShuffleTypePartVrf shuffle type: PartVrf ShuffleTypePartVrf )
const DebugCatchup = false
DebugCatchup define whether catch up now
const (
//MaxMsgPacketPayloadSize define
MaxMsgPacketPayloadSize = 10 * 1024 * 1024
)
Variables ¶
var ( ErrInvalidVoteSignature = errors.New("Error invalid vote signature") ErrInvalidVoteReplySignature = errors.New("Error invalid vote reply signature") ErrInvalidNotifySignature = errors.New("Error invalid notify signature") )
Errors define
var ( // InitStateType 为状态机的初始状态 InitStateType = 1 // VotingStateType 为状态机的投票状态 VotingStateType = 2 // VotedStateType 为状态机的已投票状态 VotedStateType = 3 // WaitNotifyStateType 为状态机的等待通知状态 WaitNotifyStateType = 4 // StateTypeMapping 为状态的整型值和字符串值的对应关系 StateTypeMapping = map[int]string{ InitStateType: "InitState", VotingStateType: "VotingState", VotedStateType: "VotedState", WaitNotifyStateType: "WaitNotifyState", } )
var InitStateObj = &InitState{}
InitStateObj is the InitState obj
var LastCheckRegTopNTime = int64(0)
LastCheckRegTopNTime is the Last Check Reg TopN Time
var LastCheckUpdateTopNTime = int64(0)
LastCheckUpdateTopNTime is the Last Check Update TopN Time
var LastCheckVrfMTime = int64(0)
LastCheckVrfMTime is the Last Check Vrf M Time
var LastCheckVrfRPTime = int64(0)
LastCheckVrfRPTime is the Last Check Vrf RP Time
var VotedStateObj = &VotedState{}
VotedStateObj is the VotedState obj
var VotingStateObj = &VotingState{}
VotingStateObj is the VotingState obj
var WaitNotifyStateObj = &WaitNofifyState{}
WaitNotifyStateObj is the WaitNotifyState obj
Functions ¶
func GenAddressByPubKey ¶
GenAddressByPubKey method
Types ¶
type Client ¶
type Client struct { //config *drivers.BaseClient // contains filtered or unexported fields }
Client Tendermint implementation
func (*Client) CheckBlock ¶
CheckBlock 暂不检查任何的交易
func (*Client) CheckTxDup ¶
func (client *Client) CheckTxDup(txs []*types.Transaction, height int64) (transactions []*types.Transaction)
CheckTxDup check transactions that duplicate
func (*Client) CmpBestBlock ¶
CmpBestBlock 比较newBlock是不是最优区块
func (*Client) CreateBlock ¶
func (client *Client) CreateBlock()
CreateBlock a routine monitor whether some transactions available and tell client by available channel
func (*Client) CreateGenesisTx ¶
func (client *Client) CreateGenesisTx() (ret []*types.Transaction)
CreateGenesisTx ...
func (*Client) CreateRecordCBTx ¶
func (client *Client) CreateRecordCBTx(info *dty.DposCBInfo) (tx *types.Transaction, err error)
CreateRecordCBTx create the tx to record cb
func (*Client) CreateRegVrfMTx ¶
func (client *Client) CreateRegVrfMTx(info *dty.DposVrfMRegist) (tx *types.Transaction, err error)
CreateRegVrfMTx create the tx to regist Vrf M
func (*Client) CreateRegVrfRPTx ¶
func (client *Client) CreateRegVrfRPTx(info *dty.DposVrfRPRegist) (tx *types.Transaction, err error)
CreateRegVrfRPTx create the tx to regist Vrf RP
func (*Client) CreateTopNRegistTx ¶
func (client *Client) CreateTopNRegistTx(reg *dty.TopNCandidatorRegist) (tx *types.Transaction, err error)
CreateTopNRegistTx create tx to regist topN
func (*Client) GenesisDoc ¶
func (client *Client) GenesisDoc() *ttypes.GenesisDoc
GenesisDoc returns the Node's GenesisDoc.
func (*Client) GetConsensusState ¶
func (client *Client) GetConsensusState() *ConsensusState
GetConsensusState return the pointer to ConsensusState
func (*Client) GetGenesisBlockTime ¶
GetGenesisBlockTime ...
func (*Client) PrivValidator ¶
func (client *Client) PrivValidator() ttypes.PrivValidator
PrivValidator returns the Node's PrivValidator.
func (*Client) QueryCandidators ¶
func (client *Client) QueryCandidators() ([]*dty.Candidator, error)
QueryCandidators query the topN candidators from blockchain
func (*Client) QueryTopNCandidators ¶
func (client *Client) QueryTopNCandidators(version int64) (*dty.TopNCandidators, error)
QueryTopNCandidators method
func (*Client) QueryVrfInfos ¶
QueryVrfInfos query the vrf infos by pubkeys
func (*Client) SetBlockTime ¶
SetBlockTime set current block time to generate new block
func (*Client) SetQueueClient ¶
SetQueueClient ...
func (*Client) StartConsensus ¶
func (client *Client) StartConsensus()
StartConsensus a routine that make the consensus start
func (*Client) ValidatorIndex ¶
ValidatorIndex get the index of local this validator if it's
type ConsensusState ¶
type ConsensusState struct { Quit chan struct{} // contains filtered or unexported fields }
ConsensusState handles execution of the consensus algorithm.
func NewConsensusState ¶
func NewConsensusState(client *Client, valMgr ValidatorMgr) *ConsensusState
NewConsensusState returns a new ConsensusState.
func (*ConsensusState) AddVotes ¶
func (cs *ConsensusState) AddVotes(vote *dpostype.DPosVote)
AddVotes method
func (*ConsensusState) CacheNotify ¶
func (cs *ConsensusState) CacheNotify(notify *dpostype.DPosNotify)
CacheNotify method
func (*ConsensusState) CacheVotes ¶
func (cs *ConsensusState) CacheVotes(vote *dpostype.DPosVote)
CacheVotes method
func (*ConsensusState) CheckVotes ¶
func (cs *ConsensusState) CheckVotes() (ty int, vote *dpostype.VoteItem)
CheckVotes method
func (*ConsensusState) ClearCachedNotify ¶
func (cs *ConsensusState) ClearCachedNotify()
ClearCachedNotify method
func (*ConsensusState) ClearCachedVotes ¶
func (cs *ConsensusState) ClearCachedVotes()
ClearCachedVotes method
func (*ConsensusState) GetCBInfoByCircle ¶
func (cs *ConsensusState) GetCBInfoByCircle(cycle int64) (info *dty.DposCBInfo)
GetCBInfoByCircle method
func (*ConsensusState) GetLastestTopNCandidators ¶
func (cs *ConsensusState) GetLastestTopNCandidators() (info *dty.TopNCandidators)
GetLastestTopNCandidators method
func (*ConsensusState) GetPrivValidator ¶
func (cs *ConsensusState) GetPrivValidator() ttypes.PrivValidator
GetPrivValidator returns the pointer of PrivValidator
func (*ConsensusState) GetTopNCandidatorsByVersion ¶
func (cs *ConsensusState) GetTopNCandidatorsByVersion(version int64) (info *dty.TopNCandidators)
GetTopNCandidatorsByVersion method
func (*ConsensusState) GetValidatorMgr ¶
func (cs *ConsensusState) GetValidatorMgr() ValidatorMgr
GetValidatorMgr returns a copy of the ValidatorMgr.
func (*ConsensusState) GetValidators ¶
func (cs *ConsensusState) GetValidators() []*ttypes.Validator
GetValidators returns a copy of the current validators.
func (*ConsensusState) GetVrfInfoByCircle ¶
func (cs *ConsensusState) GetVrfInfoByCircle(cycle int64, ty int) (info *dty.VrfInfo)
GetVrfInfoByCircle method
func (*ConsensusState) GetVrfInfosByCircle ¶
func (cs *ConsensusState) GetVrfInfosByCircle(cycle int64) (infos []*dty.VrfInfo)
GetVrfInfosByCircle method
func (*ConsensusState) InitCycleBoundaryInfo ¶
func (cs *ConsensusState) InitCycleBoundaryInfo(task Task)
InitCycleBoundaryInfo method
func (*ConsensusState) InitCycleVrfInfo ¶
func (cs *ConsensusState) InitCycleVrfInfo(task Task)
InitCycleVrfInfo method
func (*ConsensusState) InitCycleVrfInfos ¶
func (cs *ConsensusState) InitCycleVrfInfos(task Task)
InitCycleVrfInfos method
func (*ConsensusState) InitTopNCandidators ¶
func (cs *ConsensusState) InitTopNCandidators(version int64)
InitTopNCandidators method
func (*ConsensusState) IsInTopN ¶
func (cs *ConsensusState) IsInTopN(info *dty.TopNCandidators) bool
IsInTopN method
func (*ConsensusState) IsTopNRegisted ¶
func (cs *ConsensusState) IsTopNRegisted(info *dty.TopNCandidators) bool
IsTopNRegisted method
func (*ConsensusState) QueryCycleBoundaryInfo ¶
func (cs *ConsensusState) QueryCycleBoundaryInfo(cycle int64) (*dty.DposCBInfo, error)
QueryCycleBoundaryInfo method
func (*ConsensusState) QueryVrfs ¶
func (cs *ConsensusState) QueryVrfs(set *ttypes.ValidatorSet, cycle int64) (infos []*dty.VrfInfo, err error)
QueryVrfs method
func (*ConsensusState) SendCBTx ¶
func (cs *ConsensusState) SendCBTx(info *dty.DposCBInfo) bool
SendCBTx method
func (*ConsensusState) SendRegistVrfMTx ¶
func (cs *ConsensusState) SendRegistVrfMTx(info *dty.DposVrfMRegist) bool
SendRegistVrfMTx method
func (*ConsensusState) SendRegistVrfRPTx ¶
func (cs *ConsensusState) SendRegistVrfRPTx(info *dty.DposVrfRPRegist) bool
SendRegistVrfRPTx method
func (*ConsensusState) SendTopNRegistTx ¶
func (cs *ConsensusState) SendTopNRegistTx(reg *dty.TopNCandidatorRegist) bool
SendTopNRegistTx method
func (*ConsensusState) SetBroadcastChannel ¶
func (cs *ConsensusState) SetBroadcastChannel(broadcastChannel chan<- MsgInfo)
SetBroadcastChannel method
func (*ConsensusState) SetCurrentVote ¶
func (cs *ConsensusState) SetCurrentVote(vote *dpostype.VoteItem)
SetCurrentVote method
func (*ConsensusState) SetMyVote ¶
func (cs *ConsensusState) SetMyVote(vote *dpostype.DPosVote)
SetMyVote method
func (*ConsensusState) SetNotify ¶
func (cs *ConsensusState) SetNotify(notify *dpostype.DPosNotify)
SetNotify method
func (*ConsensusState) SetPrivValidator ¶
func (cs *ConsensusState) SetPrivValidator(priv ttypes.PrivValidator, index int)
SetPrivValidator sets the private validator account for signing votes.
func (*ConsensusState) ShuffleValidators ¶
func (cs *ConsensusState) ShuffleValidators(cycle int64)
ShuffleValidators method
func (*ConsensusState) Start ¶
func (cs *ConsensusState) Start()
Start It start first time starts the timeout receive routines.
func (*ConsensusState) String ¶
func (cs *ConsensusState) String() string
---------------------------------------- String returns a string.
func (*ConsensusState) UpdateCBInfo ¶
func (cs *ConsensusState) UpdateCBInfo(info *dty.DposCBInfo)
UpdateCBInfo method
func (*ConsensusState) UpdateTopNCandidators ¶
func (cs *ConsensusState) UpdateTopNCandidators(info *dty.TopNCandidators)
UpdateTopNCandidators method
func (*ConsensusState) UpdateVrfInfo ¶
func (cs *ConsensusState) UpdateVrfInfo(info *dty.VrfInfo)
UpdateVrfInfo method
func (*ConsensusState) UpdateVrfInfos ¶
func (cs *ConsensusState) UpdateVrfInfos(cycle int64, infos []*dty.VrfInfo)
UpdateVrfInfos method
func (*ConsensusState) VerifyCBInfo ¶
func (cs *ConsensusState) VerifyCBInfo(info *dty.DposCBInfo) bool
VerifyCBInfo method
func (*ConsensusState) VerifyNotify ¶
func (cs *ConsensusState) VerifyNotify(notify *dpostype.DPosNotify) bool
VerifyNotify method
func (*ConsensusState) VerifyVote ¶
func (cs *ConsensusState) VerifyVote(vote *dpostype.DPosVote) bool
VerifyVote method
func (*ConsensusState) VrfEvaluate ¶
func (cs *ConsensusState) VrfEvaluate(input []byte) (hash [32]byte, proof []byte)
VrfEvaluate method
type IP2IPPort ¶
type IP2IPPort struct {
// contains filtered or unexported fields
}
IP2IPPort struct
type Node ¶
type Node struct { Network string Version string ID ID IP string //get ip from connect to ourself // contains filtered or unexported fields }
Node struct
func NewNode ¶
func NewNode(seeds []string, protocol string, lAddr string, privKey crypto.PrivKey, network string, version string, state *ConsensusState) *Node
NewNode method
func (*Node) BroadcastRoutine ¶
func (node *Node) BroadcastRoutine()
BroadcastRoutine receive to broadcast
func (*Node) CompatibleWith ¶
CompatibleWith one node by nodeInfo
func (*Node) DialPeerWithAddress ¶
DialPeerWithAddress ...
func (*Node) FilterConnByAddr ¶
FilterConnByAddr TODO:can make fileter by addr
func (*Node) StartConsensusRoutine ¶
func (node *Node) StartConsensusRoutine()
StartConsensusRoutine if peers reached the threshold start consensus routine
func (*Node) StopPeerForError ¶
StopPeerForError called if error occurred
type NodeInfo ¶
type NodeInfo struct { ID ID `json:"id"` Network string `json:"network"` Version string `json:"version"` IP string `json:"ip,omitempty"` }
NodeInfo struct
type Peer ¶
type Peer interface { ID() ID RemoteIP() (net.IP, error) // remote IP of the connection RemoteAddr() (net.Addr, error) IsOutbound() bool IsPersistent() bool Send(msg MsgInfo) bool TrySend(msg MsgInfo) bool Stop() SetTransferChannel(chan MsgInfo) }
Peer interface
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
PeerSet struct
func (*PeerSet) Add ¶
Add adds the peer to the PeerSet. It returns an error carrying the reason, if the peer is already present.
func (*PeerSet) Has ¶
Has returns true if the set contains the peer referred to by this peerKey, otherwise false.
func (*PeerSet) HasIP ¶
HasIP returns true if the set contains the peer referred to by this IP address, otherwise false.
type SecretConnection ¶
type SecretConnection struct {
// contains filtered or unexported fields
}
SecretConnection Implements net.Conn
func MakeSecretConnection ¶
func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKey) (*SecretConnection, error)
MakeSecretConnection Performs handshake and returns a new authenticated SecretConnection. Returns nil if error in handshake. Caller should call conn.Close() See docs/sts-final.pdf for more information.
func (*SecretConnection) Close ¶
func (sc *SecretConnection) Close() error
Close Implements net.Conn
func (*SecretConnection) Read ¶
func (sc *SecretConnection) Read(data []byte) (n int, err error)
CONTRACT: data smaller than dataMaxSize is read atomically.
func (*SecretConnection) RemoteAddr ¶
func (sc *SecretConnection) RemoteAddr() net.Addr
RemoteAddr ...
func (*SecretConnection) RemotePubKey ¶
func (sc *SecretConnection) RemotePubKey() crypto.PubKey
RemotePubKey Returns authenticated remote pubkey
func (*SecretConnection) SetDeadline ¶
func (sc *SecretConnection) SetDeadline(t time.Time) error
SetDeadline ...
func (*SecretConnection) SetReadDeadline ¶
func (sc *SecretConnection) SetReadDeadline(t time.Time) error
SetReadDeadline ...
func (*SecretConnection) SetWriteDeadline ¶
func (sc *SecretConnection) SetWriteDeadline(t time.Time) error
SetWriteDeadline ...
type StackError ¶
type StackError struct { Err interface{} Stack []byte }
StackError struct
func (StackError) Error ¶
func (se StackError) Error() string
func (StackError) String ¶
func (se StackError) String() string
type State ¶
type State interface {
// contains filtered or unexported methods
}
State is the base class of dpos state machine, it defines some interfaces.
type Task ¶
type Task struct { NodeID int64 Cycle int64 CycleStart int64 CycleStop int64 PeriodStart int64 PeriodStop int64 BlockStart int64 BlockStop int64 }
Task 为计算当前时间所属周期的数据结构
func DecideTaskByTime ¶
DecideTaskByTime 根据时间戳计算所属的周期,包括cycle周期,负责出块周期,当前出块周期
type TopNVersionInfo ¶
type TopNVersionInfo struct { Version int64 HeightStart int64 HeightStop int64 HeightToStart int64 HeightRegLimit int64 HeightUpdateLimit int64 }
TopNVersionInfo 为记录某一个区块高度对应的TopN更新的版本信息
func CalcTopNVersion ¶
func CalcTopNVersion(height int64) (info TopNVersionInfo)
CalcTopNVersion 根据某一个区块高度计算对应的TopN更新的版本信息
type ValidatorMgr ¶
type ValidatorMgr struct { // Immutable ChainID string // Validators are persisted to the database separately every time they change, // so we can query for historical validator sets. // Note that if s.LastBlockHeight causes a valset change, // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 Validators *ttypes.ValidatorSet VrfValidators *ttypes.ValidatorSet NoVrfValidators *ttypes.ValidatorSet LastCycleBoundaryInfo *dty.DposCBInfo ShuffleCycle int64 ShuffleType int64 //0-no vrf 1-vrf 2-part vrf // The latest AppHash we've received from calling abci.Commit() AppHash []byte }
ValidatorMgr ...
func MakeGenesisValidatorMgr ¶
func MakeGenesisValidatorMgr(genDoc *ttypes.GenesisDoc) (ValidatorMgr, error)
MakeGenesisValidatorMgr creates validators from ttypes.GenesisDoc.
func (ValidatorMgr) Bytes ¶
func (s ValidatorMgr) Bytes() []byte
Bytes serializes the State using go-wire.
func (ValidatorMgr) Copy ¶
func (s ValidatorMgr) Copy() ValidatorMgr
Copy makes a copy of the State for mutating.
func (ValidatorMgr) Equals ¶
func (s ValidatorMgr) Equals(s2 ValidatorMgr) bool
Equals returns true if the States are identical.
func (*ValidatorMgr) FillVoteItem ¶
func (s *ValidatorMgr) FillVoteItem(voteItem *ttypes.VoteItem)
FillVoteItem method
func (*ValidatorMgr) GetIndexByPubKey ¶
func (s *ValidatorMgr) GetIndexByPubKey(pubkey []byte) (index int)
GetIndexByPubKey method
func (*ValidatorMgr) GetValidatorByIndex ¶
func (s *ValidatorMgr) GetValidatorByIndex(index int) (addr []byte, val *ttypes.Validator)
GetValidatorByIndex method
func (ValidatorMgr) GetValidators ¶
func (s ValidatorMgr) GetValidators() (current *ttypes.ValidatorSet)
GetValidators returns the last and current validator sets.
func (ValidatorMgr) IsEmpty ¶
func (s ValidatorMgr) IsEmpty() bool
IsEmpty returns true if the State is equal to the empty State.
func (*ValidatorMgr) UpdateFromVoteItem ¶
func (s *ValidatorMgr) UpdateFromVoteItem(voteItem *ttypes.VoteItem) bool
UpdateFromVoteItem method
type VotedState ¶
type VotedState struct { }
VotedState is the voted state of dpos state machine after getting an agreement for a period
type VotingState ¶
type VotingState struct { }
VotingState is the voting state of dpos state machine until timeout or get an agreement by votes.
type WaitNofifyState ¶
type WaitNofifyState struct { }
WaitNofifyState is the state of dpos state machine to wait notify.