fixes from review

This commit is contained in:
Ethan Buchman
2018-04-27 10:29:05 -04:00
parent f67c5a9e7b
commit c45ba2967a
3 changed files with 11 additions and 5 deletions

View File

@ -56,9 +56,9 @@ type VoteSet struct {
height int64
round int
type_ byte
valSet *ValidatorSet
mtx sync.Mutex
valSet *ValidatorSet
votesBitArray *cmn.BitArray
votes []*Vote // Primary votes to share
sum int64 // Sum of voting power for seen votes, discounting conflicts
@ -399,6 +399,8 @@ func (voteSet *VoteSet) HasTwoThirdsAny() bool {
}
func (voteSet *VoteSet) HasAll() bool {
voteSet.mtx.Lock()
defer voteSet.mtx.Unlock()
return voteSet.sum == voteSet.valSet.TotalVotingPower()
}
@ -424,6 +426,8 @@ func (voteSet *VoteSet) String() string {
}
func (voteSet *VoteSet) StringIndented(indent string) string {
voteSet.mtx.Lock()
defer voteSet.mtx.Unlock()
voteStrings := make([]string, len(voteSet.votes))
for i, vote := range voteSet.votes {
if vote == nil {
@ -448,6 +452,8 @@ func (voteSet *VoteSet) StringIndented(indent string) string {
// Marshal the VoteSet to JSON. Same as String(), just in JSON,
// and without the height/round/type_ (since its already included in the votes).
func (voteSet *VoteSet) MarshalJSON() ([]byte, error) {
voteSet.mtx.Lock()
defer voteSet.mtx.Unlock()
voteStrings := make([]string, len(voteSet.votes))
for i, vote := range voteSet.votes {
if vote == nil {