Commit 0d1c412f authored by Andreas Bigger's avatar Andreas Bigger

Address coordinator changes

parent b8b39edb
...@@ -64,12 +64,8 @@ func (c *coordinator) schedule(ctx context.Context, games []common.Address) erro ...@@ -64,12 +64,8 @@ func (c *coordinator) schedule(ctx context.Context, games []common.Address) erro
if j, err := c.createJob(addr); err != nil { if j, err := c.createJob(addr); err != nil {
errs = append(errs, err) errs = append(errs, err)
} else if j != nil { } else if j != nil {
if j.status == types.GameStatusInProgress { jobs = append(jobs, *j)
jobs = append(jobs, *j) c.m.RecordGameUpdateScheduled()
c.m.RecordGameUpdateScheduled()
} else {
c.logger.Warn("Resolved game update not scheduled", "game", addr, "status", j.status)
}
} }
state, ok := c.states[addr] state, ok := c.states[addr]
if ok { if ok {
...@@ -97,7 +93,6 @@ func (c *coordinator) schedule(ctx context.Context, games []common.Address) erro ...@@ -97,7 +93,6 @@ func (c *coordinator) schedule(ctx context.Context, games []common.Address) erro
// createJob updates the state for the specified game and returns the job to enqueue for it, if any // createJob updates the state for the specified game and returns the job to enqueue for it, if any
// Returns (nil, nil) when there is no error and no job to enqueue // Returns (nil, nil) when there is no error and no job to enqueue
func (c *coordinator) createJob(game common.Address) (*job, error) { func (c *coordinator) createJob(game common.Address) (*job, error) {
j := &job{addr: game}
state, ok := c.states[game] state, ok := c.states[game]
if !ok { if !ok {
state = &gameState{} state = &gameState{}
...@@ -117,9 +112,11 @@ func (c *coordinator) createJob(game common.Address) (*job, error) { ...@@ -117,9 +112,11 @@ func (c *coordinator) createJob(game common.Address) (*job, error) {
state.status = player.Status() state.status = player.Status()
} }
state.inflight = true state.inflight = true
j.player = state.player if state.status != types.GameStatusInProgress {
j.status = state.status c.logger.Debug("Not rescheduling resolved game", "game", game, "status", state.status)
return j, nil return nil, nil
}
return &job{addr: game, player: state.player, status: state.status}, nil
} }
func (c *coordinator) enqueueJob(ctx context.Context, j job) error { func (c *coordinator) enqueueJob(ctx context.Context, j job) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment