mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
ethdb: remove memory batch lock
Batches are not safe for concurrent use.
This commit is contained in:
parent
8321a45f46
commit
97beadd4fc
1 changed files with 0 additions and 7 deletions
|
|
@ -101,21 +101,14 @@ type kv struct{ k, v []byte }
|
||||||
type memBatch struct {
|
type memBatch struct {
|
||||||
db *MemDatabase
|
db *MemDatabase
|
||||||
writes []kv
|
writes []kv
|
||||||
lock sync.RWMutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memBatch) Put(key, value []byte) error {
|
func (b *memBatch) Put(key, value []byte) error {
|
||||||
b.lock.Lock()
|
|
||||||
defer b.lock.Unlock()
|
|
||||||
|
|
||||||
b.writes = append(b.writes, kv{common.CopyBytes(key), common.CopyBytes(value)})
|
b.writes = append(b.writes, kv{common.CopyBytes(key), common.CopyBytes(value)})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memBatch) Write() error {
|
func (b *memBatch) Write() error {
|
||||||
b.lock.RLock()
|
|
||||||
defer b.lock.RUnlock()
|
|
||||||
|
|
||||||
b.db.lock.Lock()
|
b.db.lock.Lock()
|
||||||
defer b.db.lock.Unlock()
|
defer b.db.lock.Unlock()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue