aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-09-14 15:45:40 +0800
committerFelix Lange <fjl@twurst.com>2015-09-15 05:36:30 +0800
commitb25258996059439df82687cc653ed14a5a9edce1 (patch)
treec8dd42cb534b8a629425e70733c6135b58acc2fe /ethdb
parentd581dfee5fbd46f3e6c54e3fab2717105e6bd510 (diff)
downloadgo-tangerine-b25258996059439df82687cc653ed14a5a9edce1.tar
go-tangerine-b25258996059439df82687cc653ed14a5a9edce1.tar.gz
go-tangerine-b25258996059439df82687cc653ed14a5a9edce1.tar.bz2
go-tangerine-b25258996059439df82687cc653ed14a5a9edce1.tar.lz
go-tangerine-b25258996059439df82687cc653ed14a5a9edce1.tar.xz
go-tangerine-b25258996059439df82687cc653ed14a5a9edce1.tar.zst
go-tangerine-b25258996059439df82687cc653ed14a5a9edce1.zip
ethdb: remove Flush
Diffstat (limited to 'ethdb')
-rw-r--r--ethdb/database.go21
-rw-r--r--ethdb/interface.go1
-rw-r--r--ethdb/memory_database.go4
3 files changed, 8 insertions, 18 deletions
diff --git a/ethdb/database.go b/ethdb/database.go
index ad87f853d..047821c30 100644
--- a/ethdb/database.go
+++ b/ethdb/database.go
@@ -61,9 +61,7 @@ type LDBDatabase struct {
quitChan chan chan error // Quit channel to stop the metrics collection before closing the database
}
-// NewLDBDatabase returns a LevelDB wrapped object. LDBDatabase does not persist data by
-// it self but requires a background poller which syncs every X. `Flush` should be called
-// when data needs to be stored and written to disk.
+// NewLDBDatabase returns a LevelDB wrapped object.
func NewLDBDatabase(file string, cache int) (*LDBDatabase, error) {
// Calculate the cache allowance for this particular database
cache = int(float64(cache) * cacheRatio[filepath.Base(file)])
@@ -142,11 +140,6 @@ func (self *LDBDatabase) NewIterator() iterator.Iterator {
return self.db.NewIterator(nil, nil)
}
-// Flush flushes out the queue to leveldb
-func (self *LDBDatabase) Flush() error {
- return nil
-}
-
func (self *LDBDatabase) Close() {
// Stop the metrics collection to avoid internal database races
self.quitLock.Lock()
@@ -159,12 +152,14 @@ func (self *LDBDatabase) Close() {
glog.V(logger.Error).Infof("metrics failure in '%s': %v\n", self.fn, err)
}
}
- // Flush and close the database
- if err := self.Flush(); err != nil {
- glog.V(logger.Error).Infof("flushing '%s' failed: %v\n", self.fn, err)
+ err := self.db.Close()
+ if glog.V(logger.Error) {
+ if err == nil {
+ glog.Infoln("closed db:", self.fn)
+ } else {
+ glog.Errorf("error closing db %s: %v", self.fn, err)
+ }
}
- self.db.Close()
- glog.V(logger.Error).Infoln("flushed and closed db:", self.fn)
}
func (self *LDBDatabase) LDB() *leveldb.DB {
diff --git a/ethdb/interface.go b/ethdb/interface.go
index acb1b57c0..f4b787a52 100644
--- a/ethdb/interface.go
+++ b/ethdb/interface.go
@@ -21,7 +21,6 @@ type Database interface {
Get(key []byte) ([]byte, error)
Delete(key []byte) error
Close()
- Flush() error
NewBatch() Batch
}
diff --git a/ethdb/memory_database.go b/ethdb/memory_database.go
index fd5663fec..81911f23f 100644
--- a/ethdb/memory_database.go
+++ b/ethdb/memory_database.go
@@ -91,10 +91,6 @@ func (db *MemDatabase) LastKnownTD() []byte {
return data
}
-func (db *MemDatabase) Flush() error {
- return nil
-}
-
func (db *MemDatabase) NewBatch() Batch {
return &memBatch{db: db}
}