Race condition in broker library causes broker to crash
(This is the error message from s28 version of broker. Tor version will be slightly different)
http: panic serving 127.0.0.1:39380: runtime error: index out of range [0] with length 0
goroutine 105878 [running]:
net/http.(*conn).serve.func1(0xc008088aa0)
/usr/local/go/src/net/http/server.go:1800 +0x13b
panic(0x7f12dec52440, 0xc002aa3bc0)
/usr/local/go/src/runtime/panic.go:975 +0x3e7
github.com/RACECAR-GU/snowflake/broker.SnowflakeHeap.Swap(...)
/usr/local/go/pkg/mod/github.com/!r!a!c!e!c!a!r-!g!u/snowflake@v0.0.0-20211214215908-95acebd91684/broker/snowflake-heap.go:32
container/heap.Pop(0x7f12decd1f60, 0xc00030e040, 0x12, 0xc0030c5d94)
/usr/local/go/src/container/heap/heap.go:62 +0x66
github.com/RACECAR-GU/snowflake/broker.clientOffers(0xc000322570, 0x7f12decce160, 0xc009662c40, 0xc005554300)
/usr/local/go/pkg/mod/github.com/!r!a!c!e!c!a!r-!g!u/snowflake@v0.0.0-20211214215908-95acebd91684/broker/broker.go:297 +0x5c9
github.com/RACECAR-GU/snowflake/broker.SnowflakeHandler.ServeHTTP(0xc000322570, 0x7f12deca9b80, 0x7f12decce160, 0xc009662c40, 0xc005554300)
/usr/local/go/pkg/mod/github.com/!r!a!c!e!c!a!r-!g!u/snowflake@v0.0.0-20211214215908-95acebd91684/broker/broker.go:97 +0x213
net/http.(*ServeMux).ServeHTTP(0x7f12df1e8d20, 0x7f12decce160, 0xc009662c40, 0xc005554300)
/usr/local/go/src/net/http/server.go:2416 +0x1a7
net/http.serverHandler.ServeHTTP(0xc000332000, 0x7f12decce160, 0xc009662c40, 0xc005554300)
/usr/local/go/src/net/http/server.go:2836 +0xa5
net/http.(*conn).serve(0xc008088aa0, 0x7f12deccfe60, 0xc006437ec0)
/usr/local/go/src/net/http/server.go:1924 +0x86e
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2962 +0x35e