Skip to content

Commit

Permalink
Fix chunk discovery during entropy generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Berman committed Jan 27, 2025
1 parent 6b9cc4a commit 06a3567
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion apps/arweave/src/ar_chunk_storage.erl
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ get_chunk_storage_path(DataDir, StoreID) ->
filename:join([get_storage_module_path(DataDir, StoreID), ?CHUNK_DIR]).

%% @doc Return the start and end offset of the bucket containing the given offset.
%% A chunk bucket a 0-based, 256-KiB wide, 256-KiB aligned range that fully contains a chunk.
%% A chunk bucket is a 0-based, 256-KiB wide, 256-KiB aligned range that
%% ar_chunk_storage uses to index chunks. The bucket start does NOT necessarily
%% match the chunk's start offset.
-spec get_chunk_bucket_start(Offset :: non_neg_integer()) -> non_neg_integer().
get_chunk_bucket_start(Offset) ->
PaddedEndOffset = ar_block:get_chunk_padded_offset(Offset),
Expand Down
6 changes: 3 additions & 3 deletions apps/arweave/src/ar_entropy_storage.erl
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,14 @@ record_entropy(ChunkEntropy, BucketEndOffset, StoreID, RewardAddr) ->

Chunk = case IsUnpackedChunkRecorded of
true ->
case ar_chunk_storage:get(Byte, Byte, StoreID) of
StartOffset = EndOffset - ?DATA_CHUNK_SIZE,
case ar_chunk_storage:get(Byte, StartOffset, StoreID) of
not_found ->
{error, not_found};
{error, _} = Error ->
Error;
{_, UnpackedChunk} ->
ar_sync_record:delete(
EndOffset, EndOffset - ?DATA_CHUNK_SIZE, ar_data_sync, StoreID),
ar_sync_record:delete(EndOffset, StartOffset, ar_data_sync, StoreID),
ar_packing_server:encipher_replica_2_9_chunk(UnpackedChunk, ChunkEntropy)
end;
false ->
Expand Down

0 comments on commit 06a3567

Please sign in to comment.