Documentation
¶
Index ¶
- Constants
- Variables
- func BroadcastPostInfo(message []byte, infos []*NodeInfo, url string, self bool)
- func ChangeView()
- func NewBlock()
- type NodeInfo
- type Pbft
- func (pt *Pbft) CheckCommit(commit *pbftTypes.Commit) bool
- func (pt *Pbft) CheckRequest(req *pbftTypes.Request) bool
- func (pt *Pbft) CheckResponse(resp *pbftTypes.Response) bool
- func (pt *Pbft) CheckViewChange(vc *pbftTypes.ViewChange) bool
- func (pt *Pbft) ReceiveCommit(commit *pbftTypes.Commit)
- func (pt *Pbft) ReceiveRequest(req *pbftTypes.Request)
- func (pt *Pbft) ReceiveResponse(resp *pbftTypes.Response)
- func (pt *Pbft) ReceiveViewChange(vc *pbftTypes.ViewChange)
- func (pt *Pbft) Start()
- func (pt *Pbft) StopAllTimer()
Constants ¶
View Source
const ( BlockInterval = 5 NullRequestTime = 2 ViewChangeInterval = 60 )
Variables ¶
View Source
var ( CandidateLack = errors.New("the parameter candidate must be needed") NotCandidate = errors.New("the address of server is not a candidate") )
Functions ¶
func BroadcastPostInfo ¶
func ChangeView ¶
func ChangeView()
some error occurs from current primary, try to change view to next candidate
Types ¶
type NodeInfo ¶
type NodeInfo struct {
Ip string
Addr cryptoType.Address
}
type Pbft ¶
type Pbft struct {
// config of current code
NodeID uint64 `json:"node_id"`
CandidateInfo []*NodeInfo `json:"candidate_info"`
Sk *ecdsa.PrivateKey `json:"-"`
Host string `json:"host"`
Port string `json:"port"`
// pbft consensus status
N uint64 `json:"n"` // the number of total nodes
F uint64 `json:"f"` // the limit number of malicious nodes
ViewID uint64 `json:"view_id"` // view id
NewViewID uint64 `json:"new_view_id"` // next view id
ResendTime uint64 `json:"resend_time"` // resend time
// pools used to store received messages in pbft
ViewChangePool map[uint64]*commonType.Uint64Set `json:"-"`
ResponsePool map[cryptoType.Hash]*commonType.Uint64Set `json:"-"`
CommitPool map[cryptoType.Hash]*commonType.Uint64Set `json:"-"`
BlockPool map[cryptoType.Hash]*types.Block `json:"-"`
// timers used for control process of pbft
NullRequestTimer *commonType.MyTimer `json:"-"` // change view when null request received in an interval
NewBlockTimer *commonType.MyTimer `json:"-"` // create/wait for new block every 1 min
ViewChangeTimer *commonType.MyTimer `json:"-"` // view change timer used to change the primary each minute
ViewChangeResendTimer *commonType.MyTimer `json:"-"` // resend view change
BlockPassTimer *commonType.MyTimer `json:"-"` // change view when time out for a new block
ViewMu sync.Mutex `json:"-"` // mutex for view id
// contains filtered or unexported fields
}
func InitPbftConfig ¶
func InitPbftConfig(cfgPath string, bc *blockchain.Blockchain, logger *log.Logger) (*Pbft, error)
func (*Pbft) CheckRequest ¶
check the request received
func (*Pbft) CheckResponse ¶
check response response received
func (*Pbft) CheckViewChange ¶
func (pt *Pbft) CheckViewChange(vc *pbftTypes.ViewChange) bool
func (*Pbft) ReceiveCommit ¶
func (*Pbft) ReceiveRequest ¶
func (*Pbft) ReceiveResponse ¶
process response received
func (*Pbft) ReceiveViewChange ¶
func (pt *Pbft) ReceiveViewChange(vc *pbftTypes.ViewChange)
func (*Pbft) StopAllTimer ¶
func (pt *Pbft) StopAllTimer()
Click to show internal directories.
Click to hide internal directories.