diff options
author | Felix Lange <fjl@twurst.com> | 2015-08-18 19:42:21 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-09-15 05:36:30 +0800 |
commit | 8b32f10f16f19c0b8985399fafdfe31af29493a1 (patch) | |
tree | c8fc463ce665286c7e604fc56e0a7f1ac7c6fa9a /ethdb/database.go | |
parent | 8c4dab77ba48dc68073fe1df79e7000043c0f966 (diff) | |
download | dexon-8b32f10f16f19c0b8985399fafdfe31af29493a1.tar dexon-8b32f10f16f19c0b8985399fafdfe31af29493a1.tar.gz dexon-8b32f10f16f19c0b8985399fafdfe31af29493a1.tar.bz2 dexon-8b32f10f16f19c0b8985399fafdfe31af29493a1.tar.lz dexon-8b32f10f16f19c0b8985399fafdfe31af29493a1.tar.xz dexon-8b32f10f16f19c0b8985399fafdfe31af29493a1.tar.zst dexon-8b32f10f16f19c0b8985399fafdfe31af29493a1.zip |
ethdb: add NewBatch
Diffstat (limited to 'ethdb/database.go')
-rw-r--r-- | ethdb/database.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ethdb/database.go b/ethdb/database.go index 9e80e5409..ad87f853d 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -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) +} |