Skip to content

Commit

Permalink
p2p: changed if-else blocks to conform with golint (ethereum#16660)
Browse files Browse the repository at this point in the history
  • Loading branch information
GagziW authored and mariameda committed Aug 19, 2018
1 parent 2730e14 commit 520419b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
29 changes: 14 additions & 15 deletions p2p/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,20 @@ func ExpectMsg(r MsgReader, code uint64, content interface{}) error {
}
if content == nil {
return msg.Discard()
} else {
contentEnc, err := rlp.EncodeToBytes(content)
if err != nil {
panic("content encode error: " + err.Error())
}
if int(msg.Size) != len(contentEnc) {
return fmt.Errorf("message size mismatch: got %d, want %d", msg.Size, len(contentEnc))
}
actualContent, err := ioutil.ReadAll(msg.Payload)
if err != nil {
return err
}
if !bytes.Equal(actualContent, contentEnc) {
return fmt.Errorf("message payload mismatch:\ngot: %x\nwant: %x", actualContent, contentEnc)
}
}
contentEnc, err := rlp.EncodeToBytes(content)
if err != nil {
panic("content encode error: " + err.Error())
}
if int(msg.Size) != len(contentEnc) {
return fmt.Errorf("message size mismatch: got %d, want %d", msg.Size, len(contentEnc))
}
actualContent, err := ioutil.ReadAll(msg.Payload)
if err != nil {
return err
}
if !bytes.Equal(actualContent, contentEnc) {
return fmt.Errorf("message payload mismatch:\ngot: %x\nwant: %x", actualContent, contentEnc)
}
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions p2p/simulations/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,6 @@ func (self *Network) executeNodeEvent(e *Event) error {
func (self *Network) executeConnEvent(e *Event) error {
if e.Conn.Up {
return self.Connect(e.Conn.One, e.Conn.Other)
} else {
return self.Disconnect(e.Conn.One, e.Conn.Other)
}
return self.Disconnect(e.Conn.One, e.Conn.Other)
}

0 comments on commit 520419b

Please sign in to comment.