diff --git a/swarm/storage/localstore/accessor_test.go b/swarm/storage/localstore/accessor_test.go index 20a38c0445..74f4e5323f 100644 --- a/swarm/storage/localstore/accessor_test.go +++ b/swarm/storage/localstore/accessor_test.go @@ -37,7 +37,7 @@ func TestAccessors(t *testing.T) { ModeUpload, ModeRequest, ModeSynced, - ModeAccess, + modeAccess, } { t.Run(ModeName(m), func(t *testing.T) { a := db.Accessor(m) @@ -61,7 +61,7 @@ func TestAccessors(t *testing.T) { // Removal mode is a special case as it removes the chunk // from the database. - t.Run(ModeName(ModeRemoval), func(t *testing.T) { + t.Run(ModeName(modeRemoval), func(t *testing.T) { a := db.Accessor(ModeUpload) want := generateRandomChunk() @@ -80,7 +80,7 @@ func TestAccessors(t *testing.T) { t.Errorf("got chunk data %x, want %x", got.Data(), want.Data()) } - a = db.Accessor(ModeRemoval) + a = db.Accessor(modeRemoval) // removal accessor actually removes the chunk on Put err = a.Put(context.Background(), want) diff --git a/swarm/storage/localstore/mode.go b/swarm/storage/localstore/mode.go index 1fd75af570..cba7d0f89c 100644 --- a/swarm/storage/localstore/mode.go +++ b/swarm/storage/localstore/mode.go @@ -33,10 +33,11 @@ const ( ModeUpload ModeRequest ModeSynced - ModeAccess - // Q: this mode is not needed, - // as it will be used only internally for GC. - ModeRemoval + // this modes are internal only + // they can be removed completely + // if accessors are not used internally + modeAccess + modeRemoval ) // ModeName returns a descriptive name of a Mode. @@ -51,9 +52,9 @@ func ModeName(m Mode) (name string) { return "request" case ModeSynced: return "synced" - case ModeAccess: + case modeAccess: return "access" - case ModeRemoval: + case modeRemoval: return "removal" } return "" @@ -162,14 +163,14 @@ func (db *DB) updateBatch(b *batch, mode Mode, item shed.IndexItem) (err error) db.pushIndex.DeleteInBatch(b.Batch, item) db.gcIndex.PutInBatch(b.Batch, item) - case ModeAccess: + case modeAccess: // update accessTimeStamp in retrieve, gc db.gcIndex.DeleteInBatch(b.Batch, item) item.AccessTimestamp = now() db.retrievalIndex.PutInBatch(b.Batch, item) db.gcIndex.PutInBatch(b.Batch, item) - case ModeRemoval: + case modeRemoval: // delete from retrieve, pull, gc db.retrievalIndex.DeleteInBatch(b.Batch, item) db.pullIndex.DeleteInBatch(b.Batch, item)