mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-08 23:17:54 -05:00
Bonsai snapshot worldstate (#4409)
* use optimistictransactiondb for mutable isolated snapshots * plumbing necessary to have a snapshot specific updater. * snapshot rolling working * implement AutoCloseable on BonsaiSnapshotWorldState to ensure we can correctly dispose of snapshots * add snapshot transaction cloning, change snapshot based worldstate to extend persisted worldstate rather than in-memory worldstate Signed-off-by: garyschulte <garyschulte@gmail.com>
This commit is contained in:
@@ -15,24 +15,40 @@
|
||||
package org.hyperledger.besu.services.kvstore;
|
||||
|
||||
import org.hyperledger.besu.plugin.services.exception.StorageException;
|
||||
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
|
||||
import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction;
|
||||
import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier;
|
||||
import org.hyperledger.besu.plugin.services.storage.SnappableKeyValueStorage;
|
||||
import org.hyperledger.besu.plugin.services.storage.SnappedKeyValueStorage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SegmentedKeyValueStorageAdapter<S> implements KeyValueStorage {
|
||||
public class SegmentedKeyValueStorageAdapter<S> implements SnappableKeyValueStorage {
|
||||
private final S segmentHandle;
|
||||
private final SegmentedKeyValueStorage<S> storage;
|
||||
private final Supplier<SnappedKeyValueStorage> snapshotSupplier;
|
||||
|
||||
public SegmentedKeyValueStorageAdapter(
|
||||
final SegmentIdentifier segment, final SegmentedKeyValueStorage<S> storage) {
|
||||
this(
|
||||
segment,
|
||||
storage,
|
||||
() -> {
|
||||
throw new UnsupportedOperationException("Snapshot not supported");
|
||||
});
|
||||
}
|
||||
|
||||
public SegmentedKeyValueStorageAdapter(
|
||||
final SegmentIdentifier segment,
|
||||
final SegmentedKeyValueStorage<S> storage,
|
||||
final Supplier<SnappedKeyValueStorage> snapshotSupplier) {
|
||||
segmentHandle = storage.getSegmentIdentifierByName(segment);
|
||||
this.storage = storage;
|
||||
this.snapshotSupplier = snapshotSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,4 +112,9 @@ public class SegmentedKeyValueStorageAdapter<S> implements KeyValueStorage {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SnappedKeyValueStorage takeSnapshot() {
|
||||
return snapshotSupplier.get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user