|
|
@ -45,7 +45,6 @@ import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.TreeSet; |
|
|
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.function.Function; |
|
|
|
|
|
|
|
|
|
|
@ -364,27 +363,28 @@ public abstract class DiffBasedWorldStateUpdateAccumulator<ACCOUNT extends DiffB |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final TreeSet<Map.Entry<UInt256, UInt256>> entries = |
|
|
|
|
|
|
|
new TreeSet<>(Map.Entry.comparingByKey()); |
|
|
|
|
|
|
|
entries.addAll(updatedAccount.getUpdatedStorage().entrySet()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// parallel stream here may cause database corruption
|
|
|
|
// parallel stream here may cause database corruption
|
|
|
|
entries.forEach( |
|
|
|
updatedAccount |
|
|
|
storageUpdate -> { |
|
|
|
.getUpdatedStorage() |
|
|
|
final UInt256 keyUInt = storageUpdate.getKey(); |
|
|
|
.entrySet() |
|
|
|
final StorageSlotKey slotKey = |
|
|
|
.forEach( |
|
|
|
new StorageSlotKey(hashAndSaveSlotPreImage(keyUInt), Optional.of(keyUInt)); |
|
|
|
storageUpdate -> { |
|
|
|
final UInt256 value = storageUpdate.getValue(); |
|
|
|
final UInt256 keyUInt = storageUpdate.getKey(); |
|
|
|
final DiffBasedValue<UInt256> pendingValue = pendingStorageUpdates.get(slotKey); |
|
|
|
final StorageSlotKey slotKey = |
|
|
|
if (pendingValue == null) { |
|
|
|
new StorageSlotKey( |
|
|
|
pendingStorageUpdates.put( |
|
|
|
hashAndSaveSlotPreImage(keyUInt), Optional.of(keyUInt)); |
|
|
|
slotKey, |
|
|
|
final UInt256 value = storageUpdate.getValue(); |
|
|
|
new DiffBasedValue<>( |
|
|
|
final DiffBasedValue<UInt256> pendingValue = |
|
|
|
updatedAccount.getOriginalStorageValue(keyUInt), value)); |
|
|
|
pendingStorageUpdates.get(slotKey); |
|
|
|
} else { |
|
|
|
if (pendingValue == null) { |
|
|
|
pendingValue.setUpdated(value); |
|
|
|
pendingStorageUpdates.put( |
|
|
|
} |
|
|
|
slotKey, |
|
|
|
}); |
|
|
|
new DiffBasedValue<>( |
|
|
|
|
|
|
|
updatedAccount.getOriginalStorageValue(keyUInt), value)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
pendingValue.setUpdated(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
updatedAccount.getUpdatedStorage().clear(); |
|
|
|
updatedAccount.getUpdatedStorage().clear(); |
|
|
|
|
|
|
|
|
|
|
|