Exemple #1
0
// Convenience method.
// Signs the vote and sets the POL's vote at the desired index
// Returns the POLVoteSignature pointer, so you can modify it afterwards.
func signAddPOLVoteSignature(val *sm.PrivValidator, valSet *sm.ValidatorSet, vote *types.Vote, pol *POL) *POLVoteSignature {
	vote = vote.Copy()
	err := val.SignVote(vote)
	if err != nil {
		panic(err)
	}
	idx, _ := valSet.GetByAddress(val.Address) // now we have the index
	pol.Votes[idx] = POLVoteSignature{vote.Round, vote.Signature}
	return &pol.Votes[idx]
}
Exemple #2
0
// Convenience: Return new vote with different blockParts
func withBlockParts(vote *types.Vote, blockParts types.PartSetHeader) *types.Vote {
	vote = vote.Copy()
	vote.BlockParts = blockParts
	return vote
}
Exemple #3
0
// Convenience: Return new vote with different blockHash
func withBlockHash(vote *types.Vote, blockHash []byte) *types.Vote {
	vote = vote.Copy()
	vote.BlockHash = blockHash
	return vote
}
Exemple #4
0
// Convenience: Return new vote with different type
func withType(vote *types.Vote, type_ byte) *types.Vote {
	vote = vote.Copy()
	vote.Type = type_
	return vote
}
Exemple #5
0
// Convenience: Return new vote with different round
func withRound(vote *types.Vote, round uint) *types.Vote {
	vote = vote.Copy()
	vote.Round = round
	return vote
}
Exemple #6
0
// Convenience: Return new vote with different height
func withHeight(vote *types.Vote, height uint) *types.Vote {
	vote = vote.Copy()
	vote.Height = height
	return vote
}