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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
8b32f10f
Commit
8b32f10f
authored
Aug 18, 2015
by
Felix Lange
Browse files
Options
Downloads
Patches
Plain Diff
ethdb: add NewBatch
parent
8c4dab77
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ethdb/database.go
+20
-0
20 additions, 0 deletions
ethdb/database.go
ethdb/interface.go
+6
-0
6 additions, 0 deletions
ethdb/interface.go
ethdb/memory_database.go
+23
-0
23 additions, 0 deletions
ethdb/memory_database.go
with
49 additions
and
0 deletions
ethdb/database.go
+
20
−
0
View file @
8b32f10f
...
...
@@ -268,3 +268,23 @@ func (self *LDBDatabase) meter(refresh time.Duration) {
}
}
}
// TODO: remove this stuff and expose leveldb directly
func
(
db
*
LDBDatabase
)
NewBatch
()
Batch
{
return
&
ldbBatch
{
db
:
db
.
db
,
b
:
new
(
leveldb
.
Batch
)}
}
type
ldbBatch
struct
{
db
*
leveldb
.
DB
b
*
leveldb
.
Batch
}
func
(
b
*
ldbBatch
)
Put
(
key
,
value
[]
byte
)
error
{
b
.
b
.
Put
(
key
,
value
)
return
nil
}
func
(
b
*
ldbBatch
)
Write
()
error
{
return
b
.
db
.
Write
(
b
.
b
,
nil
)
}
This diff is collapsed.
Click to expand it.
ethdb/interface.go
+
6
−
0
View file @
8b32f10f
...
...
@@ -22,4 +22,10 @@ type Database interface {
Delete
(
key
[]
byte
)
error
Close
()
Flush
()
error
NewBatch
()
Batch
}
type
Batch
interface
{
Put
(
key
,
value
[]
byte
)
error
Write
()
error
}
This diff is collapsed.
Click to expand it.
ethdb/memory_database.go
+
23
−
0
View file @
8b32f10f
...
...
@@ -95,3 +95,26 @@ func (db *MemDatabase) LastKnownTD() []byte {
func
(
db
*
MemDatabase
)
Flush
()
error
{
return
nil
}
func
(
db
*
MemDatabase
)
NewBatch
()
Batch
{
return
&
memBatch
{
db
:
db
}
}
type
kv
struct
{
k
,
v
[]
byte
}
type
memBatch
struct
{
db
*
MemDatabase
writes
[]
kv
}
func
(
w
*
memBatch
)
Put
(
key
,
value
[]
byte
)
error
{
w
.
writes
=
append
(
w
.
writes
,
kv
{
key
,
common
.
CopyBytes
(
value
)})
return
nil
}
func
(
w
*
memBatch
)
Write
()
error
{
for
_
,
kv
:=
range
w
.
writes
{
w
.
db
.
db
[
string
(
kv
.
k
)]
=
kv
.
v
}
return
nil
}
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