more idiomatic copyRPC

This commit is contained in:
vyzo 2018-08-28 21:35:00 +03:00
parent 73b338aa6d
commit a3003697f6
1 changed files with 4 additions and 13 deletions

17
comm.go
View File

@ -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
}