aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@gmail.com>2015-04-22 18:46:41 +0800
committerBas van Kervel <basvankervel@gmail.com>2015-04-23 23:58:58 +0800
commitc273ed7d82f3d5beab7c213fbe1f5c0942adf0bd (patch)
tree623972174faa894c499a7ad808668cb64e17cbcd /ethdb
parent94f2adb80a54c9bddacf146138d8e218a95629c9 (diff)
downloaddexon-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar.gz
dexon-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar.zst
dexon-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.zip
Moved leveldb update loop to eth/backend
change order of block insert and update LastBlock bugfix, wrong hash stored in blockDb
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
+}