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
5479be9f
Commit
5479be9f
authored
May 27, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1129 from obscuren/database_cache_removal
ethdb, common: cache removal
parents
903b95ff
020006a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
59 deletions
+7
-59
db.go
common/db.go
+0
-1
chain_manager.go
core/chain_manager.go
+1
-0
database.go
ethdb/database.go
+6
-58
No files found.
common/db.go
View file @
5479be9f
...
...
@@ -5,7 +5,6 @@ type Database interface {
Put
(
key
[]
byte
,
value
[]
byte
)
Get
(
key
[]
byte
)
([]
byte
,
error
)
Delete
(
key
[]
byte
)
error
LastKnownTD
()
[]
byte
Close
()
Flush
()
error
}
core/chain_manager.go
View file @
5479be9f
...
...
@@ -69,6 +69,7 @@ func CalcGasLimit(parent *types.Block) *big.Int {
gl
:=
new
(
big
.
Int
)
.
Sub
(
parent
.
GasLimit
(),
decay
)
gl
=
gl
.
Add
(
gl
,
contrib
)
gl
=
gl
.
Add
(
gl
,
big
.
NewInt
(
1
))
gl
=
common
.
BigMax
(
gl
,
params
.
MinGasLimit
)
if
gl
.
Cmp
(
params
.
GenesisGasLimit
)
<
0
{
...
...
ethdb/database.go
View file @
5479be9f
package
ethdb
import
(
"sync"
"github.com/ethereum/go-ethereum/compression/rle"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
...
...
@@ -15,14 +13,10 @@ import (
var
OpenFileLimit
=
64
type
LDBDatabase
struct
{
// filename for reporting
fn
string
mu
sync
.
Mutex
// LevelDB instance
db
*
leveldb
.
DB
queue
map
[
string
][]
byte
quit
chan
struct
{}
}
// NewLDBDatabase returns a LevelDB wrapped object. LDBDatabase does not persist data by
...
...
@@ -40,85 +34,39 @@ func NewLDBDatabase(file string) (*LDBDatabase, error) {
return
nil
,
err
}
database
:=
&
LDBDatabase
{
fn
:
file
,
db
:
db
,
quit
:
make
(
chan
struct
{}),
fn
:
file
,
db
:
db
,
}
database
.
makeQueue
()
return
database
,
nil
}
func
(
self
*
LDBDatabase
)
makeQueue
()
{
self
.
queue
=
make
(
map
[
string
][]
byte
)
}
// Put puts the given key / value to the queue
func
(
self
*
LDBDatabase
)
Put
(
key
[]
byte
,
value
[]
byte
)
{
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
self
.
queue
[
string
(
key
)]
=
value
self
.
db
.
Put
(
key
,
rle
.
Compress
(
value
),
nil
)
}
// Get returns the given key if it's present.
func
(
self
*
LDBDatabase
)
Get
(
key
[]
byte
)
([]
byte
,
error
)
{
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
// Check queue first
if
dat
,
ok
:=
self
.
queue
[
string
(
key
)];
ok
{
return
dat
,
nil
}
dat
,
err
:=
self
.
db
.
Get
(
key
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
return
rle
.
Decompress
(
dat
)
}
// Delete deletes the key from the queue and database
func
(
self
*
LDBDatabase
)
Delete
(
key
[]
byte
)
error
{
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
// make sure it's not in the queue
delete
(
self
.
queue
,
string
(
key
))
return
self
.
db
.
Delete
(
key
,
nil
)
}
func
(
self
*
LDBDatabase
)
LastKnownTD
()
[]
byte
{
data
,
_
:=
self
.
Get
([]
byte
(
"LTD"
))
if
len
(
data
)
==
0
{
data
=
[]
byte
{
0x0
}
}
return
data
}
func
(
self
*
LDBDatabase
)
NewIterator
()
iterator
.
Iterator
{
return
self
.
db
.
NewIterator
(
nil
,
nil
)
}
// Flush flushes out the queue to leveldb
func
(
self
*
LDBDatabase
)
Flush
()
error
{
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
batch
:=
new
(
leveldb
.
Batch
)
for
key
,
value
:=
range
self
.
queue
{
batch
.
Put
([]
byte
(
key
),
rle
.
Compress
(
value
))
}
self
.
makeQueue
()
// reset the queue
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"Flush database: "
,
self
.
fn
)
return
self
.
db
.
Write
(
batch
,
nil
)
return
nil
}
func
(
self
*
LDBDatabase
)
Close
()
{
...
...
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