aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb
diff options
context:
space:
mode:
Diffstat (limited to 'ethdb')
-rw-r--r--ethdb/database.go28
-rw-r--r--ethdb/memory_database.go4
2 files changed, 7 insertions, 25 deletions
diff --git a/ethdb/database.go b/ethdb/database.go
index eb562f852..57a3f9ee6 100644
--- a/ethdb/database.go
+++ b/ethdb/database.go
@@ -2,7 +2,6 @@ package ethdb
import (
"sync"
- "time"
"github.com/ethereum/go-ethereum/compression/rle"
"github.com/ethereum/go-ethereum/logger"
@@ -35,8 +34,6 @@ func NewLDBDatabase(file string) (*LDBDatabase, error) {
}
database.makeQueue()
- go database.update()
-
return database, nil
}
@@ -111,35 +108,16 @@ func (self *LDBDatabase) Flush() error {
}
self.makeQueue() // reset the queue
+ glog.V(logger.Detail).Infoln("Flush database: ", self.fn)
+
return self.db.Write(batch, nil)
}
func (self *LDBDatabase) Close() {
- self.quit <- struct{}{}
- <-self.quit
- glog.V(logger.Info).Infoln("flushed and closed db:", self.fn)
-}
-
-func (self *LDBDatabase) update() {
- ticker := time.NewTicker(1 * time.Minute)
-done:
- for {
- select {
- case <-ticker.C:
- if err := self.Flush(); err != nil {
- glog.V(logger.Error).Infof("error: flush '%s': %v\n", self.fn, err)
- }
- case <-self.quit:
- break done
- }
- }
-
if err := self.Flush(); err != nil {
glog.V(logger.Error).Infof("error: flush '%s': %v\n", self.fn, err)
}
- // Close the leveldb database
self.db.Close()
-
- self.quit <- struct{}{}
+ glog.V(logger.Error).Infoln("flushed and closed db:", self.fn)
}
diff --git a/ethdb/memory_database.go b/ethdb/memory_database.go
index d4988d0d8..f5d5faee7 100644
--- a/ethdb/memory_database.go
+++ b/ethdb/memory_database.go
@@ -65,3 +65,7 @@ func (db *MemDatabase) LastKnownTD() []byte {
return data
}
+
+func (db *MemDatabase) Flush() error {
+ return nil
+}