aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb/database.go
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/database.go
parent94f2adb80a54c9bddacf146138d8e218a95629c9 (diff)
downloadgo-tangerine-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar
go-tangerine-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar.gz
go-tangerine-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar.bz2
go-tangerine-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar.lz
go-tangerine-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar.xz
go-tangerine-c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd.tar.zst
go-tangerine-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/database.go')
-rw-r--r--ethdb/database.go28
1 files changed, 3 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)
}