instantout/reservation: lock initial currentHeight write in Run

Run wrote m.currentHeight = height without holding the lock, while
later writes (newBlockChan case) and reads in
RequestReservationFromServer take m.Lock. Daemon startup serializes
'wait for initChan' before serving RPC, so in practice the race
window is short, but the race detector flags it -- and on the
nautilus side a similar pattern is the most plausible cause of the
unit-race CI failure on the buy-reservations head commit. Symmetric
fix here keeps the synchronisation rule uniform.
This commit is contained in:
Slyghtning 2026-05-11 16:58:45 +02:00
parent 29c92a10ea
commit 10a50ef452
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF

View file

@ -92,7 +92,13 @@ func (m *Manager) Run(ctx context.Context, height int32,
runCtx, cancel := context.WithCancel(ctx)
defer cancel()
// Take the lock for the initial write so the race detector sees a
// consistent synchronisation rule (later writes in the new-block
// case already lock; concurrent reads in RequestReservationFromServer
// already lock).
m.Lock()
m.currentHeight = height
m.Unlock()
err := m.RecoverReservations(runCtx)
if err != nil {