Use local type as ctx key

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2019-11-19 14:36:27 -06:00
parent 1cd584d81b
commit 6dafca7aac
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
2 changed files with 3 additions and 3 deletions

View File

@ -752,10 +752,10 @@ func (syncer *Syncer) verifyBlsAggregate(ctx context.Context, sig types.Signatur
return nil
}
const syncStateKey = "syncStateKey"
type syncStateKey struct{}
func extractSyncState(ctx context.Context) *SyncerState {
v := ctx.Value(syncStateKey)
v := ctx.Value(syncStateKey{})
if v != nil {
return v.(*SyncerState)
}

View File

@ -338,7 +338,7 @@ func (sm *SyncManager) syncWorker(id int) {
}
log.Info("sync worker go time!", ts.Height(), ts.Cids())
ctx := context.WithValue(context.TODO(), syncStateKey, ss)
ctx := context.WithValue(context.TODO(), syncStateKey{}, ss)
err := sm.doSync(ctx, ts)
if err != nil {
log.Errorf("sync error: %+v", err)