Skip to content

Commit

Permalink
No longer insert records, store them for bulk insert, fail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ferglor committed Sep 7, 2023
1 parent 231ad07 commit 6e5943b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions core/services/ocr2/plugins/ocr2keeper/evm21/upkeepstate/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,22 @@ type upkeepStateStore struct {
mu sync.RWMutex
cache map[string]*upkeepStateRecord

pendingRecords []persistedStateRecord

// service values
cancel context.CancelFunc
}

// NewUpkeepStateStore creates a new state store
func NewUpkeepStateStore(orm ORM, lggr logger.Logger, scanner PerformedLogsScanner) *upkeepStateStore {
return &upkeepStateStore{
orm: orm,
lggr: lggr.Named("UpkeepStateStore"),
cache: map[string]*upkeepStateRecord{},
scanner: scanner,
retention: CacheExpiration,
cleanCadence: GCInterval,
orm: orm,
lggr: lggr.Named("UpkeepStateStore"),
cache: map[string]*upkeepStateRecord{},
scanner: scanner,
retention: CacheExpiration,
cleanCadence: GCInterval,
pendingRecords: []persistedStateRecord{},
}
}

Expand Down Expand Up @@ -200,13 +203,15 @@ func (u *upkeepStateStore) upsertStateRecord(ctx context.Context, workID string,

u.cache[workID] = record

return u.orm.BatchInsertUpkeepStates([]persistedStateRecord{{
u.pendingRecords = append(u.pendingRecords, persistedStateRecord{
UpkeepID: utils.NewBig(upkeepID),
WorkID: record.workID,
CompletionState: uint8(record.state),
IneligibilityReason: reason,
InsertedAt: record.addedAt,
}}, pg.WithParentCtx(ctx))
})

return nil
}

// fetchPerformed fetches all performed logs from the scanner to populate the cache.
Expand Down

0 comments on commit 6e5943b

Please sign in to comment.