Browse Source

fixes from review

pull/1511/head
Ethan Buchman 7 years ago
parent
commit
c45ba2967a
3 changed files with 11 additions and 5 deletions
  1. +2
    -2
      node/node.go
  2. +2
    -2
      types/part_set.go
  3. +7
    -1
      types/vote_set.go

+ 2
- 2
node/node.go View File

@ -402,7 +402,7 @@ func (n *Node) OnStart() error {
// Add ourselves to addrbook to prevent dialing ourselves
n.addrBook.AddOurAddress(nodeInfo.NetAddress())
// Run the RPC server first
// Start the RPC server before the P2P server
// so we can eg. receive txs for the first block
if n.config.RPC.ListenAddress != "" {
listeners, err := n.startRPC()
@ -412,7 +412,7 @@ func (n *Node) OnStart() error {
n.rpcListeners = listeners
}
// Start the switch
// Start the switch (the P2P server).
err = n.sw.Start()
if err != nil {
return err


+ 2
- 2
types/part_set.go View File

@ -267,7 +267,7 @@ func (ps *PartSet) StringShort() string {
func (ps *PartSet) MarshalJSON() ([]byte, error) {
if ps == nil {
return []byte("nil-PartSet"), nil
return []byte("{}"), nil
}
ps.mtx.Lock()
@ -278,6 +278,6 @@ func (ps *PartSet) MarshalJSON() ([]byte, error) {
PartsBitArray *cmn.BitArray `json:"parts_bit_array"`
}{
fmt.Sprintf("%d/%d", ps.Count(), ps.Total()),
ps.partsBitArray.Copy(),
ps.partsBitArray,
})
}

+ 7
- 1
types/vote_set.go 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 {


Loading…
Cancel
Save