Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Berman committed Mar 29, 2024
1 parent deb70d9 commit 8ef211e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 1 addition & 2 deletions apps/arweave/src/ar_data_sync.erl
Expand Up @@ -220,11 +220,10 @@ add_chunk(DataRoot, DataPath, Chunk, Offset, TXSize) ->
%% relative end offset to end up in one of the configured storage modules.
is_estimated_long_term_chunk(DataRootOffsetReply, EndOffset) ->
WeaveSize = ar_node:get_current_weave_size(),
IsTipCovered = is_offset_vicinity_covered(WeaveSize),
case DataRootOffsetReply of
not_found ->
%% A chunk from a pending transaction.
IsTipCovered;
is_offset_vicinity_covered(WeaveSize);
{ok, {TXStartOffset, _}} ->
WeaveSize = ar_node:get_current_weave_size(),
Size = ar_node:get_recent_max_block_size(),
Expand Down
12 changes: 10 additions & 2 deletions apps/arweave/src/ar_storage_module.erl
Expand Up @@ -4,6 +4,8 @@
get_by_id/1, get_range/1, get_packing/1, get_size/1, get/2, get_all/1, get_all/2,
has_any/1, has_range/2]).

-export([get_unique_sorted_intervals/1]).

-include_lib("arweave/include/ar.hrl").
-include_lib("arweave/include/ar_consensus.hrl").
-include_lib("arweave/include/ar_config.hrl").
Expand Down Expand Up @@ -183,8 +185,14 @@ has_any(Offset) ->
%% @doc Return true if the given range is covered by the configured storage modules.
has_range(Start, End) ->
{ok, Config} = application:get_env(arweave, config),
Intervals = get_unique_sorted_intervals(Config#config.storage_modules),
has_range(Start, End, Intervals).
case ets:lookup(?MODULE, unique_sorted_intervals) of
[] ->
Intervals = get_unique_sorted_intervals(Config#config.storage_modules),
ets:insert(?MODULE, {unique_sorted_intervals, Intervals}),
has_range(Start, End, Intervals);
[{_, Intervals}] ->
has_range(Start, End, Intervals)
end.

%%%===================================================================
%%% Private functions.
Expand Down

0 comments on commit 8ef211e

Please sign in to comment.