proposer selection tests. closes #53

This commit is contained in:
Ethan Buchman
2015-11-10 13:41:49 -08:00
committed by Jae Kwon
parent d69b5c5ab6
commit 209bcf905e
5 changed files with 217 additions and 56 deletions
+15 -4
View File
@@ -166,13 +166,16 @@ type ConsensusState struct {
evsw events.Fireable
evc *events.EventCache // set in stageBlock and passed into state
decideProposalFunc func(cs *ConsensusState, height int, round int)
}
func NewConsensusState(state *sm.State, blockStore *bc.BlockStore, mempoolReactor *mempl.MempoolReactor) *ConsensusState {
cs := &ConsensusState{
blockStore: blockStore,
mempoolReactor: mempoolReactor,
newStepCh: make(chan *RoundState, 10),
blockStore: blockStore,
mempoolReactor: mempoolReactor,
newStepCh: make(chan *RoundState, 10),
decideProposalFunc: decideProposal,
}
cs.updateToState(state)
// Don't call scheduleRound0 yet.
@@ -182,6 +185,10 @@ func NewConsensusState(state *sm.State, blockStore *bc.BlockStore, mempoolReacto
return cs
}
func (cs *ConsensusState) SetDecideProposalFunc(f func(cs *ConsensusState, height int, round int)) {
cs.decideProposalFunc = f
}
// Reconstruct LastCommit from SeenValidation, which we saved along with the block,
// (which happens even before saving the state)
func (cs *ConsensusState) reconstructLastCommit(state *sm.State) {
@@ -418,8 +425,12 @@ func (cs *ConsensusState) EnterPropose(height int, round int) {
}
}
func (cs *ConsensusState) decideProposal(height, round int) {
cs.decideProposalFunc(cs, height, round)
}
// Decides on the next proposal and sets them onto cs.Proposal*
func (cs *ConsensusState) decideProposal(height int, round int) {
func decideProposal(cs *ConsensusState, height, round int) {
var block *types.Block
var blockParts *types.PartSet