diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiPreImageProxy.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiPreImageProxy.java index 42a86ce36b2..248e5d895fd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiPreImageProxy.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiPreImageProxy.java @@ -37,35 +37,11 @@ public interface BonsaiPreImageProxy extends WorldStatePreimageStorage { */ Hash hashAndSavePreImage(Bytes value); - /** PreImageProxy which does not store or cache preImages and only implements hashing. */ - class NoOpPreImageProxy implements BonsaiPreImageProxy { - - @Override - public Hash hashAndSavePreImage(final Bytes value) { - return Hash.hash(value); - } - - @Override - public Optional getStorageTrieKeyPreimage(final Bytes32 trieKey) { - return Optional.empty(); - } - - @Override - public Optional
getAccountTrieKeyPreimage(final Bytes32 trieKey) { - return Optional.empty(); - } - - @Override - public Updater updater() { - throw new UnsupportedOperationException("NoOpPreImageProxy does not implement an updater"); - } - } - /** * A caching PreImageProxy suitable for ReferenceTestWorldState which saves hashes in an unbounded * BiMap. */ - class BonsaiReferenceTestPreImageProxy extends NoOpPreImageProxy { + class BonsaiReferenceTestPreImageProxy implements BonsaiPreImageProxy { BiMap preImageCache = HashBiMap.create(); @Override @@ -82,5 +58,11 @@ public Optional getStorageTrieKeyPreimage(final Bytes32 trieKey) { public Optional
getAccountTrieKeyPreimage(final Bytes32 trieKey) { return Optional.ofNullable(preImageCache.get(trieKey)).map(Address::wrap); } + + @Override + public Updater updater() { + throw new UnsupportedOperationException( + "BonsaiReferenceTestPreImageProxy does not implement an updater"); + } } } diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBSnapshotTransaction.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBSnapshotTransaction.java index 5d058bbaddb..0897493eb19 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBSnapshotTransaction.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBSnapshotTransaction.java @@ -166,7 +166,15 @@ public Stream streamKeys(final SegmentIdentifier segmentId) { rocksIterator.seekToFirst(); return RocksDbIterator.create(rocksIterator).toStreamKeys(); } - + /** + * Returns a stream of key-value pairs starting from the specified key. This method is used to + * retrieve a stream of data reading through the transaction, starting from the given key. If no + * data is available from the specified key onwards, an empty stream is returned. + * + * @param segment The segment identifier whose keys we want to stream. + * @param startKey The key from which the stream should start. + * @return A stream of key-value pairs starting from the specified key. + */ public Stream> streamFromKey( final SegmentIdentifier segment, final byte[] startKey) { throwIfClosed(); @@ -177,6 +185,17 @@ public Stream> streamFromKey( return RocksDbIterator.create(rocksIterator).toStream(); } + /** + * Returns a stream of key-value pairs starting from the specified key, ending at the specified + * key. This method is used to retrieve a stream of data reading through the transaction, starting + * from the given key. If no data is available from the specified key onwards, an empty stream is + * returned. + * + * @param segment The segment identifier whose keys we want to stream. + * @param startKey The key from which the stream should start. + * @param endKey The key at which the stream should stop. + * @return A stream of key-value pairs starting from the specified key. + */ public Stream> streamFromKey( final SegmentIdentifier segment, final byte[] startKey, final byte[] endKey) { throwIfClosed();