]> Cypherpunks.ru repositories - nncp.git/commitdiff
Possibly daemon has not connected to any node, do not segfault
authorSergey Matveev <stargrave@stargrave.org>
Mon, 9 Jan 2017 18:25:22 +0000 (21:25 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 9 Jan 2017 18:56:43 +0000 (21:56 +0300)
src/cypherpunks.ru/nncp/cmd/nncp-daemon/main.go

index a9bfcfee0ad5170b4a326b31d674852d3a51950c..176c935a11aa90268264c4f475717f01e020111e 100644 (file)
@@ -101,7 +101,13 @@ func main() {
                                        "txspeed":  strconv.FormatInt(state.TxSpeed, 10),
                                }, "")
                        } else {
-                               ctx.LogE("call-start", nncp.SDS{"node": state.NodeId, "err": err}, "")
+                               var nodeId string
+                               if state == nil {
+                                       nodeId = "unknown"
+                               } else {
+                                       nodeId = state.NodeId.String()
+                               }
+                               ctx.LogE("call-start", nncp.SDS{"node": nodeId, "err": err}, "")
                        }
                        conn.Close()
                }(conn)