mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/storage/localstore: call writeGCSize on DB Close
This commit is contained in:
parent
b5a0fd285f
commit
4fca004e86
2 changed files with 11 additions and 1 deletions
|
|
@ -278,7 +278,12 @@ func TestDB_gcSize(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
err = db.Close()
|
||||
// DB.Close writes gc size to disk, so
|
||||
// Instead calling Close, simulate database shutdown
|
||||
// without it.
|
||||
close(db.close)
|
||||
db.updateGCWG.Wait()
|
||||
err = db.shed.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ import (
|
|||
"encoding/hex"
|
||||
"errors"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/shed"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mock"
|
||||
|
|
@ -344,6 +346,9 @@ func New(path string, baseKey []byte, o *Options) (db *DB, err error) {
|
|||
func (db *DB) Close() (err error) {
|
||||
close(db.close)
|
||||
db.updateGCWG.Wait()
|
||||
if err := db.writeGCSize(atomic.LoadInt64(&db.gcSize)); err != nil {
|
||||
log.Error("localstore: write gc size", "err", err)
|
||||
}
|
||||
return db.shed.Close()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue