Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
b2525899
Commit
b2525899
authored
9 years ago
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethdb: remove Flush
parent
d581dfee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
51 deletions
+10
-51
backend.go
eth/backend.go
+2
-33
database.go
ethdb/database.go
+8
-13
interface.go
ethdb/interface.go
+0
-1
memory_database.go
ethdb/memory_database.go
+0
-4
No files found.
eth/backend.go
View file @
b2525899
...
...
@@ -213,9 +213,6 @@ type Ethereum struct {
chainDb
ethdb
.
Database
// Block chain database
dappDb
ethdb
.
Database
// Dapp database
// Closed when databases are flushed and closed
databasesClosed
chan
bool
//*** SERVICES ***
// State manager for processing new blocks and managing the over all states
blockProcessor
*
core
.
BlockProcessor
...
...
@@ -337,7 +334,6 @@ func New(config *Config) (*Ethereum, error) {
eth
:=
&
Ethereum
{
shutdownChan
:
make
(
chan
bool
),
databasesClosed
:
make
(
chan
bool
),
chainDb
:
chainDb
,
dappDb
:
dappDb
,
eventMux
:
&
event
.
TypeMux
{},
...
...
@@ -549,8 +545,6 @@ func (s *Ethereum) Start() error {
if
err
!=
nil
{
return
err
}
// periodically flush databases
go
s
.
syncDatabases
()
if
s
.
AutoDAG
{
s
.
StartAutoDAG
()
...
...
@@ -566,32 +560,6 @@ func (s *Ethereum) Start() error {
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
()
{
jsonlogger
.
LogJson
(
&
logger
.
LogStarting
{
ClientString
:
s
.
net
.
Name
,
...
...
@@ -622,12 +590,13 @@ func (s *Ethereum) Stop() {
}
s
.
StopAutoDAG
()
s
.
chainDb
.
Close
()
s
.
dappDb
.
Close
()
close
(
s
.
shutdownChan
)
}
// This function will wait for a shutdown and resumes main thread execution
func
(
s
*
Ethereum
)
WaitForShutdown
()
{
<-
s
.
databasesClosed
<-
s
.
shutdownChan
}
...
...
This diff is collapsed.
Click to expand it.
ethdb/database.go
View file @
b2525899
...
...
@@ -61,9 +61,7 @@ type LDBDatabase struct {
quitChan
chan
chan
error
// Quit channel to stop the metrics collection before closing the database
}
// NewLDBDatabase returns a LevelDB wrapped object. LDBDatabase does not persist data by
// it self but requires a background poller which syncs every X. `Flush` should be called
// when data needs to be stored and written to disk.
// NewLDBDatabase returns a LevelDB wrapped object.
func
NewLDBDatabase
(
file
string
,
cache
int
)
(
*
LDBDatabase
,
error
)
{
// Calculate the cache allowance for this particular database
cache
=
int
(
float64
(
cache
)
*
cacheRatio
[
filepath
.
Base
(
file
)])
...
...
@@ -142,11 +140,6 @@ func (self *LDBDatabase) NewIterator() iterator.Iterator {
return
self
.
db
.
NewIterator
(
nil
,
nil
)
}
// Flush flushes out the queue to leveldb
func
(
self
*
LDBDatabase
)
Flush
()
error
{
return
nil
}
func
(
self
*
LDBDatabase
)
Close
()
{
// Stop the metrics collection to avoid internal database races
self
.
quitLock
.
Lock
()
...
...
@@ -159,12 +152,14 @@ func (self *LDBDatabase) Close() {
glog
.
V
(
logger
.
Error
)
.
Infof
(
"metrics failure in '%s': %v
\n
"
,
self
.
fn
,
err
)
}
}
// Flush and close the database
if
err
:=
self
.
Flush
();
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"flushing '%s' failed: %v
\n
"
,
self
.
fn
,
err
)
err
:=
self
.
db
.
Close
()
if
glog
.
V
(
logger
.
Error
)
{
if
err
==
nil
{
glog
.
Infoln
(
"closed db:"
,
self
.
fn
)
}
else
{
glog
.
Errorf
(
"error closing db %s: %v"
,
self
.
fn
,
err
)
}
}
self
.
db
.
Close
()
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"flushed and closed db:"
,
self
.
fn
)
}
func
(
self
*
LDBDatabase
)
LDB
()
*
leveldb
.
DB
{
...
...
This diff is collapsed.
Click to expand it.
ethdb/interface.go
View file @
b2525899
...
...
@@ -21,7 +21,6 @@ type Database interface {
Get
(
key
[]
byte
)
([]
byte
,
error
)
Delete
(
key
[]
byte
)
error
Close
()
Flush
()
error
NewBatch
()
Batch
}
...
...
This diff is collapsed.
Click to expand it.
ethdb/memory_database.go
View file @
b2525899
...
...
@@ -91,10 +91,6 @@ func (db *MemDatabase) LastKnownTD() []byte {
return
data
}
func
(
db
*
MemDatabase
)
Flush
()
error
{
return
nil
}
func
(
db
*
MemDatabase
)
NewBatch
()
Batch
{
return
&
memBatch
{
db
:
db
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment