|
|
@ -213,9 +213,6 @@ type Ethereum struct { |
|
|
|
chainDb ethdb.Database // Block chain database
|
|
|
|
chainDb ethdb.Database // Block chain database
|
|
|
|
dappDb ethdb.Database // Dapp database
|
|
|
|
dappDb ethdb.Database // Dapp database
|
|
|
|
|
|
|
|
|
|
|
|
// Closed when databases are flushed and closed
|
|
|
|
|
|
|
|
databasesClosed chan bool |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//*** SERVICES ***
|
|
|
|
//*** SERVICES ***
|
|
|
|
// State manager for processing new blocks and managing the over all states
|
|
|
|
// State manager for processing new blocks and managing the over all states
|
|
|
|
blockProcessor *core.BlockProcessor |
|
|
|
blockProcessor *core.BlockProcessor |
|
|
@ -337,7 +334,6 @@ func New(config *Config) (*Ethereum, error) { |
|
|
|
|
|
|
|
|
|
|
|
eth := &Ethereum{ |
|
|
|
eth := &Ethereum{ |
|
|
|
shutdownChan: make(chan bool), |
|
|
|
shutdownChan: make(chan bool), |
|
|
|
databasesClosed: make(chan bool), |
|
|
|
|
|
|
|
chainDb: chainDb, |
|
|
|
chainDb: chainDb, |
|
|
|
dappDb: dappDb, |
|
|
|
dappDb: dappDb, |
|
|
|
eventMux: &event.TypeMux{}, |
|
|
|
eventMux: &event.TypeMux{}, |
|
|
@ -549,8 +545,6 @@ func (s *Ethereum) Start() error { |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
// periodically flush databases
|
|
|
|
|
|
|
|
go s.syncDatabases() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if s.AutoDAG { |
|
|
|
if s.AutoDAG { |
|
|
|
s.StartAutoDAG() |
|
|
|
s.StartAutoDAG() |
|
|
@ -566,32 +560,6 @@ func (s *Ethereum) Start() error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// sync databases every minute. If flushing fails we exit immediatly. The system
|
|
|
|
|
|
|
|
// may not continue under any circumstances.
|
|
|
|
|
|
|
|
func (s *Ethereum) syncDatabases() { |
|
|
|
|
|
|
|
ticker := time.NewTicker(1 * time.Minute) |
|
|
|
|
|
|
|
done: |
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
select { |
|
|
|
|
|
|
|
case <-ticker.C: |
|
|
|
|
|
|
|
// don't change the order of database flushes
|
|
|
|
|
|
|
|
if err := s.dappDb.Flush(); err != nil { |
|
|
|
|
|
|
|
glog.Fatalf("fatal error: flush dappDb: %v (Restart your node. We are aware of this issue)\n", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if err := s.chainDb.Flush(); err != nil { |
|
|
|
|
|
|
|
glog.Fatalf("fatal error: flush chainDb: %v (Restart your node. We are aware of this issue)\n", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case <-s.shutdownChan: |
|
|
|
|
|
|
|
break done |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.chainDb.Close() |
|
|
|
|
|
|
|
s.dappDb.Close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
close(s.databasesClosed) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *Ethereum) StartForTest() { |
|
|
|
func (s *Ethereum) StartForTest() { |
|
|
|
jsonlogger.LogJson(&logger.LogStarting{ |
|
|
|
jsonlogger.LogJson(&logger.LogStarting{ |
|
|
|
ClientString: s.net.Name, |
|
|
|
ClientString: s.net.Name, |
|
|
@ -622,12 +590,13 @@ func (s *Ethereum) Stop() { |
|
|
|
} |
|
|
|
} |
|
|
|
s.StopAutoDAG() |
|
|
|
s.StopAutoDAG() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.chainDb.Close() |
|
|
|
|
|
|
|
s.dappDb.Close() |
|
|
|
close(s.shutdownChan) |
|
|
|
close(s.shutdownChan) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// This function will wait for a shutdown and resumes main thread execution
|
|
|
|
// This function will wait for a shutdown and resumes main thread execution
|
|
|
|
func (s *Ethereum) WaitForShutdown() { |
|
|
|
func (s *Ethereum) WaitForShutdown() { |
|
|
|
<-s.databasesClosed |
|
|
|
|
|
|
|
<-s.shutdownChan |
|
|
|
<-s.shutdownChan |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|