good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
020006a8
Commit
020006a8
authored
9 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
common, ethdb: removed caching and LastTD
parent
75957168
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/db.go
+0
-1
0 additions, 1 deletion
common/db.go
ethdb/database.go
+6
-58
6 additions, 58 deletions
ethdb/database.go
with
6 additions
and
59 deletions
common/db.go
+
0
−
1
View file @
020006a8
...
...
@@ -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
}
This diff is collapsed.
Click to expand it.
ethdb/database.go
+
6
−
58
View file @
020006a8
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
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment