Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ar_data_sync: Skip unpacking if the chunk was downloaded from the local peer #637

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix reviewers comments
  • Loading branch information
shizzard committed Nov 14, 2024
commit 5f5d75cf3023f44a2f4cb40da880164aadd6f02a
12 changes: 7 additions & 5 deletions apps/arweave/src/ar_data_sync.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2815,7 +2815,7 @@ process_invalid_fetched_chunk(Peer, Byte, State) ->

process_valid_fetched_chunk(ChunkArgs, Args, State) ->
#sync_data_state{ store_id = StoreID } = State,
{Packing, UnpackedChunk, AbsoluteEndOffset, TXRoot, ChunkSize} = ChunkArgs,
{FetchedPacking, FetchedChunk, AbsoluteEndOffset, TXRoot, ChunkSize} = ChunkArgs,
{AbsoluteTXStartOffset, TXSize, DataPath, TXPath, DataRoot, Chunk, _ChunkID,
ChunkEndOffset, Peer, Byte} = Args,
case is_chunk_proof_ratio_attractive(ChunkSize, TXSize, DataPath) of
Expand All @@ -2831,16 +2831,18 @@ process_valid_fetched_chunk(ChunkArgs, Args, State) ->
%% The chunk has been synced by another job already.
decrement_chunk_cache_size(),
{noreply, State};
false when Packing =/= unpacked ->
false when FetchedPacking =/= unpacked ->
%% we don't have unpacked chunk, so possible repack is needed
true = AbsoluteEndOffset == AbsoluteTXStartOffset + ChunkEndOffset,
pack_and_store_chunk({DataRoot, AbsoluteEndOffset, TXPath, TXRoot,
DataPath, Packing, ChunkEndOffset, ChunkSize, Chunk,
DataPath, FetchedPacking, ChunkEndOffset, ChunkSize, Chunk,
none, none, none}, State);
shizzard marked this conversation as resolved.
Show resolved Hide resolved
false ->
%% process unpacked chunk
true = AbsoluteEndOffset == AbsoluteTXStartOffset + ChunkEndOffset,
pack_and_store_chunk({DataRoot, AbsoluteEndOffset, TXPath, TXRoot,
DataPath, Packing, ChunkEndOffset, ChunkSize, Chunk,
UnpackedChunk, none, none}, State)
DataPath, FetchedPacking, ChunkEndOffset, ChunkSize, Chunk,
FetchedChunk, none, none}, State)
end
end.

Expand Down
2 changes: 0 additions & 2 deletions apps/arweave/src/ar_serialize.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2120,8 +2120,6 @@ encode_packing(spora_2_5, _Strict) ->
encode_packing(unpacked, _Strict) ->
"unpacked".

decode_packing(<<"any">>, _Error) ->
any;
decode_packing(<<"unpacked">>, _Error) ->
unpacked;
decode_packing(<<"spora_2_5">>, _Error) ->
Expand Down
Loading