From c273ed7d82f3d5beab7c213fbe1f5c0942adf0bd Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 22 Apr 2015 12:46:41 +0200 Subject: Moved leveldb update loop to eth/backend change order of block insert and update LastBlock bugfix, wrong hash stored in blockDb --- ethdb/database.go | 28 +++------------------------- ethdb/memory_database.go | 4 ++++ 2 files changed, 7 insertions(+), 25 deletions(-) (limited to 'ethdb') 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 +} -- cgit