optimize usage of bart (#1395)
Some checks failed
gofmt / Run gofmt (push) Successful in 9s
smoke-extra / Run extra smoke tests (push) Failing after 19s
smoke / Run multi node smoke test (push) Failing after 1m19s
Build and test / Build all and test on ubuntu-linux (push) Failing after 18m41s
Build and test / Build and test on linux with boringcrypto (push) Failing after 2m47s
Build and test / Build and test on linux with pkcs11 (push) Failing after 2m47s
Build and test / Build and test on macos-latest (push) Has been cancelled
Build and test / Build and test on windows-latest (push) Has been cancelled

Use `bart.Lite` and `.Contains` as suggested by the bart maintainer:

- 9455952eed (commitcomment-155362580)
This commit is contained in:
Wade Simmons
2025-04-18 12:37:20 -04:00
committed by GitHub
parent 4eb056af9d
commit b8ea55eb90
13 changed files with 61 additions and 80 deletions

View File

@@ -223,7 +223,7 @@ type HostInfo struct {
recvError atomic.Uint32
// networks are both all vpn and unsafe networks assigned to this host
networks *bart.Table[struct{}]
networks *bart.Lite
relayState RelayState
// HandshakePacket records the packets used to create this hostinfo
@@ -732,13 +732,13 @@ func (i *HostInfo) buildNetworks(networks, unsafeNetworks []netip.Prefix) {
return
}
i.networks = new(bart.Table[struct{}])
i.networks = new(bart.Lite)
for _, network := range networks {
i.networks.Insert(network, struct{}{})
i.networks.Insert(network)
}
for _, network := range unsafeNetworks {
i.networks.Insert(network, struct{}{})
i.networks.Insert(network)
}
}