types/netmap: move some mutations earlier, remove, document some fields

And optimize the Persist setting a bit, allocating later and only mutating
fields when there's been a Node change.

Updates #1909

Change-Id: Iaddfd9e88ef76e1d18e8d0a41926eb44d0955312
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-08-20 15:17:25 -07:00
committed by Brad Fitzpatrick
parent 21170fb175
commit 165f0116f1
5 changed files with 87 additions and 40 deletions

View File

@@ -446,10 +446,11 @@ func TestNetmapForResponse(t *testing.T) {
ComputedNameWithHost: "foo",
}
ms := newTestMapSession(t)
nm1 := ms.netmapForResponse(&tailcfg.MapResponse{
mapRes := &tailcfg.MapResponse{
Node: someNode,
})
}
initDisplayNames(mapRes.Node.View(), mapRes)
nm1 := ms.netmapForResponse(mapRes)
if nm1.SelfNode == nil {
t.Fatal("nil Node in 1st netmap")
}