mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
same problem in MVHashMap.Write
This commit is contained in:
parent
dfe484d6a2
commit
aa00c8f96c
1 changed files with 9 additions and 20 deletions
|
|
@ -121,34 +121,23 @@ func (mv *MVHashMap) Write(k Key, v Version, data interface{}) {
|
|||
return
|
||||
})
|
||||
|
||||
cells.rw.RLock()
|
||||
ci, ok := cells.tm.Get(v.TxnIndex)
|
||||
cells.rw.RUnlock()
|
||||
|
||||
if ok {
|
||||
cells.rw.Lock()
|
||||
if ci, ok := cells.tm.Get(v.TxnIndex); !ok {
|
||||
cells.tm.Put(v.TxnIndex, &WriteCell{
|
||||
flag: FlagDone,
|
||||
incarnation: v.Incarnation,
|
||||
data: data,
|
||||
})
|
||||
} else {
|
||||
if ci.(*WriteCell).incarnation > v.Incarnation {
|
||||
panic(fmt.Errorf("existing transaction value does not have lower incarnation: %v, %v",
|
||||
k, v.TxnIndex))
|
||||
}
|
||||
|
||||
ci.(*WriteCell).flag = FlagDone
|
||||
ci.(*WriteCell).incarnation = v.Incarnation
|
||||
ci.(*WriteCell).data = data
|
||||
} else {
|
||||
cells.rw.Lock()
|
||||
if ci, ok = cells.tm.Get(v.TxnIndex); !ok {
|
||||
cells.tm.Put(v.TxnIndex, &WriteCell{
|
||||
flag: FlagDone,
|
||||
incarnation: v.Incarnation,
|
||||
data: data,
|
||||
})
|
||||
} else {
|
||||
ci.(*WriteCell).flag = FlagDone
|
||||
ci.(*WriteCell).incarnation = v.Incarnation
|
||||
ci.(*WriteCell).data = data
|
||||
}
|
||||
cells.rw.Unlock()
|
||||
}
|
||||
cells.rw.Unlock()
|
||||
}
|
||||
|
||||
func (mv *MVHashMap) ReadStorage(k Key, fallBack func() any) any {
|
||||
|
|
|
|||
Loading…
Reference in a new issue