From 47db1fa245800a85adbfee3e831497a787a21fc9 Mon Sep 17 00:00:00 2001 From: lash Date: Fri, 12 Oct 2018 10:31:58 +0200 Subject: [PATCH] swarm/storage: Remove comment --- swarm/storage/ldbstore.go | 16 ++++++++-------- swarm/storage/ldbstore_test.go | 18 ------------------ 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go index ab90a6708c..e6f277110d 100644 --- a/swarm/storage/ldbstore.go +++ b/swarm/storage/ldbstore.go @@ -95,13 +95,13 @@ func NewLDBStoreParams(storeparams *StoreParams, path string) *LDBStoreParams { } type garbage struct { - maxRound int // maximum number of chunks to delete in one garbage collection round - maxBatch int // maximum number of chunks to delete in one db request batch - ratio int // 1/x ratio to calculate the number of chunks to gc on a low capacity db - count int // number of chunks deleted in running round - target int // number of chunks to delete in running round - batch *dbBatch // the delete batch - runC chan struct{} + maxRound int // maximum number of chunks to delete in one garbage collection round + maxBatch int // maximum number of chunks to delete in one db request batch + ratio int // 1/x ratio to calculate the number of chunks to gc on a low capacity db + count int // number of chunks deleted in running round + target int // number of chunks to delete in running round + batch *dbBatch // the delete batch + runC chan struct{} // struct in chan means gc is NOT running } type LDBStore struct { @@ -187,6 +187,7 @@ func NewLDBStore(params *LDBStoreParams) (s *LDBStore, err error) { maxRound: defaultMaxGCRound, ratio: defaultGCRatio, } + s.gc.runC = make(chan struct{}, 1) s.gc.runC <- struct{}{} @@ -313,7 +314,6 @@ func decodeData(addr Address, data []byte) (*chunk, error) { func (s *LDBStore) collectGarbage() error { // prevent duplicate gc from starting when one is already running - // runC contains a struct{} as long as we are NOT running if len(s.gc.runC) == 0 { return nil } diff --git a/swarm/storage/ldbstore_test.go b/swarm/storage/ldbstore_test.go index e1a4d0bae1..92a6759404 100644 --- a/swarm/storage/ldbstore_test.go +++ b/swarm/storage/ldbstore_test.go @@ -589,21 +589,3 @@ func waitGc(ctx context.Context, ldb *LDBStore) { <-ldb.gc.runC ldb.gc.runC <- struct{}{} } - -//func waitGc(ctx context.Context, ldb *LDBStore) error { -// ticker := time.Tick(time.Millisecond * 100) -// for { -// select { -// -// case <-ctx.Done(): -// return errors.New("timeout") -// case <-ticker: -// ldb.lock.Lock() -// running := ldb.gc.running -// ldb.lock.Unlock() -// if !running { -// return nil -// } -// } -// } -//}