From 36928b716c52f1354dd8e46115bf15b62c0774a2 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Wed, 15 Jan 2020 19:45:43 +0000 Subject: [PATCH] Fixed bug:m network.proto backwards compatibility unmarshal --- network/node.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/network/node.go b/network/node.go index d632e299..e740ad73 100644 --- a/network/node.go +++ b/network/node.go @@ -70,12 +70,22 @@ func newStatus() *status { } func newPeerStatus(peer *pb.Peer) *status { - return &status{ - err: &nerr{ - count: int(peer.Node.Status.Error.Count), - msg: errors.New(peer.Node.Status.Error.Msg), - }, + status := &status{ + err: new(nerr), } + + // if Node.Status is nil, return empty status + if peer.Node.Status == nil { + return status + } + + // if peer.Node.Status.Error is NOT nil, update status fields + if err := peer.Node.Status.GetError(); err != nil { + status.err.count = int(peer.Node.Status.Error.Count) + status.err.msg = errors.New(peer.Node.Status.Error.Msg) + } + + return status } func (s *status) Error() Error {