use helper function for constructing state updates (#2410)
This helps preventing messages being sent with the wrong update type and payload combination, and it is shorter/neater. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
b92bd3d27e
commit
1f0110fe06
9 changed files with 56 additions and 107 deletions
|
@ -17,6 +17,7 @@ import (
|
|||
"gorm.io/gorm"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/ptr"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -626,11 +627,7 @@ func enableRoutes(tx *gorm.DB,
|
|||
|
||||
node.Routes = nRoutes
|
||||
|
||||
return &types.StateUpdate{
|
||||
Type: types.StatePeerChanged,
|
||||
ChangeNodes: []types.NodeID{node.ID},
|
||||
Message: "created in db.enableRoutes",
|
||||
}, nil
|
||||
return ptr.To(types.UpdatePeerChanged(node.ID)), nil
|
||||
}
|
||||
|
||||
func generateGivenName(suppliedName string, randomSuffix bool) (string, error) {
|
||||
|
@ -717,10 +714,7 @@ func ExpireExpiredNodes(tx *gorm.DB,
|
|||
}
|
||||
|
||||
if len(expired) > 0 {
|
||||
return started, types.StateUpdate{
|
||||
Type: types.StatePeerChangedPatch,
|
||||
ChangePatches: expired,
|
||||
}, true
|
||||
return started, types.UpdatePeerPatch(expired...), true
|
||||
}
|
||||
|
||||
return started, types.StateUpdate{}, false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue