From a3003697f666db06486b801fc9b3ed0bdf3305a6 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 28 Aug 2018 21:35:00 +0300 Subject: [PATCH] more idiomatic copyRPC --- comm.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/comm.go b/comm.go index f679fc4..fded9a8 100644 --- a/comm.go +++ b/comm.go @@ -124,20 +124,11 @@ func rpcWithControl(msgs []*pb.Message, } func copyRPC(rpc *RPC) *RPC { - res := &RPC{ - RPC: pb.RPC{ - Subscriptions: rpc.Subscriptions, - Publish: rpc.Publish, - }, - from: rpc.from, - } + res := new(RPC) + *res = *rpc if rpc.Control != nil { - res.Control = &pb.ControlMessage{ - Ihave: rpc.Control.Ihave, - Iwant: rpc.Control.Iwant, - Graft: rpc.Control.Graft, - Prune: rpc.Control.Prune, - } + res.Control = new(pb.ControlMessage) + *res.Control = *rpc.Control } return res }