|
|
@ -34,6 +34,17 @@ var errLeaderPriKeyNotFound = errors.New("leader private key not found locally") |
|
|
|
// ProposalType is to indicate the type of signal for new block proposal
|
|
|
|
// ProposalType is to indicate the type of signal for new block proposal
|
|
|
|
type ProposalType byte |
|
|
|
type ProposalType byte |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proposal is to indicate the type of signal for new block proposal
|
|
|
|
|
|
|
|
type Proposal struct { |
|
|
|
|
|
|
|
Type ProposalType |
|
|
|
|
|
|
|
Message string |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewProposal creates a new proposal
|
|
|
|
|
|
|
|
func NewProposal(t ProposalType) Proposal { |
|
|
|
|
|
|
|
return Proposal{Type: t, Message: utils.FileNo()} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Constant of the type of new block proposal
|
|
|
|
// Constant of the type of new block proposal
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
SyncProposal ProposalType = iota |
|
|
|
SyncProposal ProposalType = iota |
|
|
@ -90,7 +101,7 @@ type Consensus struct { |
|
|
|
// ViewChange struct
|
|
|
|
// ViewChange struct
|
|
|
|
vc *viewChange |
|
|
|
vc *viewChange |
|
|
|
// Signal channel for proposing a new block and start new consensus
|
|
|
|
// Signal channel for proposing a new block and start new consensus
|
|
|
|
readySignal chan ProposalType |
|
|
|
readySignal chan Proposal |
|
|
|
// Channel to send full commit signatures to finish new block proposal
|
|
|
|
// Channel to send full commit signatures to finish new block proposal
|
|
|
|
commitSigChannel chan []byte |
|
|
|
commitSigChannel chan []byte |
|
|
|
// The post-consensus job func passed from Node object
|
|
|
|
// The post-consensus job func passed from Node object
|
|
|
@ -151,11 +162,11 @@ func (consensus *Consensus) ChainReader() engine.ChainReader { |
|
|
|
return consensus.Blockchain() |
|
|
|
return consensus.Blockchain() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (consensus *Consensus) ReadySignal(p ProposalType) { |
|
|
|
func (consensus *Consensus) ReadySignal(p Proposal) { |
|
|
|
consensus.readySignal <- p |
|
|
|
consensus.readySignal <- p |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (consensus *Consensus) GetReadySignal() chan ProposalType { |
|
|
|
func (consensus *Consensus) GetReadySignal() chan Proposal { |
|
|
|
return consensus.readySignal |
|
|
|
return consensus.readySignal |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -304,7 +315,7 @@ func New( |
|
|
|
// displayed on explorer as Height right now
|
|
|
|
// displayed on explorer as Height right now
|
|
|
|
consensus.setCurBlockViewID(0) |
|
|
|
consensus.setCurBlockViewID(0) |
|
|
|
consensus.SlashChan = make(chan slash.Record) |
|
|
|
consensus.SlashChan = make(chan slash.Record) |
|
|
|
consensus.readySignal = make(chan ProposalType) |
|
|
|
consensus.readySignal = make(chan Proposal) |
|
|
|
consensus.commitSigChannel = make(chan []byte) |
|
|
|
consensus.commitSigChannel = make(chan []byte) |
|
|
|
// channel for receiving newly generated VDF
|
|
|
|
// channel for receiving newly generated VDF
|
|
|
|
consensus.RndChannel = make(chan [vdfAndSeedSize]byte) |
|
|
|
consensus.RndChannel = make(chan [vdfAndSeedSize]byte) |
|
|
|