fix: preempt prover from planning with no workers

This commit is contained in:
Cassandra Heart 2025-10-07 00:14:35 -05:00
parent 006ef46731
commit 036d94a4fa
No known key found for this signature in database
GPG Key ID: 371083BFA6C240AA

View File

@ -1,6 +1,7 @@
package global
import (
"bytes"
"encoding/hex"
"fmt"
"math/rand"
@ -81,7 +82,18 @@ func (e *GlobalConsensusEngine) eventDistributorLoop() {
e.publishKeyRegistry()
}
if e.proposer != nil {
e.evaluateForProposals(data)
workers, err := e.workerManager.RangeWorkers()
if err != nil {
e.logger.Error("could not retrieve workers", zap.Error(err))
} else {
allocated := true
for _, w := range workers {
allocated = allocated && w.Allocated
}
if !allocated {
e.evaluateForProposals(data)
}
}
}
}
@ -402,6 +414,17 @@ func (e *GlobalConsensusEngine) evaluateForProposals(
continue
}
allocated := false
for _, prover := range info {
if bytes.Equal(prover.Address, e.getProverAddress()) {
allocated = true
}
}
if allocated {
continue
}
size := e.hypergraph.GetSize(&key, path)
resp, err := e.hypergraph.GetChildrenForPath(
e.ctx,