[crash] fix nil pointer error #749

Signed-off-by: Leo Chen <leo@harmony.one>
pull/796/head
Leo Chen 6 years ago
parent cdcdb925ff
commit a46514120d
  1. 3
      p2p/host/hostv2/hostv2.go

@ -87,6 +87,9 @@ func (r *GroupReceiverImpl) Close() error {
func (r *GroupReceiverImpl) Receive(ctx context.Context) (
msg []byte, sender libp2p_peer.ID, err error,
) {
if r.sub == nil {
return nil, libp2p_peer.ID(""), fmt.Errorf("Receive: r.sub == nil")
}
m, err := r.sub.Next(ctx)
if err == nil {
msg = m.Data

Loading…
Cancel
Save