Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Prefix ROCKSDB_ to ITERATOR_CLOSE
Browse files Browse the repository at this point in the history
  • Loading branch information
xandkar committed Jun 21, 2022
1 parent 9ddcc51 commit 7cd8b38
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/blockchain.erl
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ find_first_height_after(MinHeight0, #blockchain{db=DB, heights=HeightsCF}) ->
lager:error("Unexpected iterator error: ~p", [Reason]),
{error, not_found}
end,
?ITERATOR_CLOSE(Iter),
?ROCKSDB_ITERATOR_CLOSE(Iter),
Result.

find_first_block_after(MinHeight, Blockchain) ->
Expand Down Expand Up @@ -2090,7 +2090,7 @@ rocksdb_gc(BytesToDrop, #blockchain{db=DB, heights=HeightsCF}=Blockchain) ->
%% start at 2 here so we don't GC the genesis block
{ok, Itr} = rocksdb:iterator(DB, HeightsCF, [{iterate_lower_bound, <<2:64/integer-unsigned-big>>}, {iterate_upper_bound, <<CutoffHeight:64/integer-unsigned-big>>}]),
ok = do_rocksdb_gc(BytesToDrop, Itr, Blockchain, rocksdb:iterator_move(Itr, first)),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
ok.

do_rocksdb_gc(_, _, _, {error, Reason}) ->
Expand Down Expand Up @@ -3024,7 +3024,7 @@ check_plausible_blocks(#blockchain{db=DB}=Chain, GossipedHash) ->
get_plausible_blocks(#blockchain{db=DB, plausible_blocks=CF}) ->
{ok, Itr} = rocksdb:iterator(DB, CF, []),
Res = get_plausible_blocks(Itr, rocksdb:iterator_move(Itr, first), []),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Res.

get_plausible_blocks(_Itr, {error, _}, Acc) ->
Expand Down
2 changes: 1 addition & 1 deletion src/blockchain_rocks.hrl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-define(ITERATOR_CLOSE(IteratorHandle),
-define(ROCKSDB_ITERATOR_CLOSE(IteratorHandle),
%% Wrapping in fun to avoid scope leakage:
(fun() ->
try
Expand Down
10 changes: 5 additions & 5 deletions src/ledger/v1/blockchain_aux_ledger_v1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ overall_diff_rewards_md_sums(Ledger) ->
[]
),
Res = overall_diff_rewards_md_sums_(rocksdb:iterator_move(Itr, last), #{}),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Res.

%% ==================================================================
Expand All @@ -499,7 +499,7 @@ get_rewards_md_(Ledger) ->
[]
),
Res = get_aux_rewards_md_(Itr, rocksdb:iterator_move(Itr, first), #{}),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Res.

get_aux_rewards_md_(_Itr, {error, _}, Acc) ->
Expand Down Expand Up @@ -528,7 +528,7 @@ get_rewards_md_sums_(Ledger) ->
[]
),
Res = get_aux_rewards_md_sums_(Itr, rocksdb:iterator_move(Itr, first), #{}),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Res.

get_aux_rewards_md_sums_(_Itr, {error, _}, Acc) ->
Expand Down Expand Up @@ -557,7 +557,7 @@ get_rewards_md_diff_(Ledger) ->
[]
),
Res = get_aux_rewards_md_diff_(Itr, rocksdb:iterator_move(Itr, first), #{}),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Res.

get_aux_rewards_md_diff_(_Itr, {error, _}, Acc) ->
Expand Down Expand Up @@ -723,7 +723,7 @@ get_rewards_(Ledger) ->
[]
),
Res = get_rewards_(Itr, rocksdb:iterator_move(Itr, first), #{}),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Res.

get_rewards_(_Itr, {error, _}, Acc) ->
Expand Down
8 changes: 4 additions & 4 deletions src/ledger/v1/blockchain_ledger_v1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ process_poc_proposals(BlockHeight, BlockHash, Ledger) ->
{ok, Itr} = rocksdb:iterator(DB, CF, []),
POCSubset = promote_proposals(K, BlockHash, BlockHeight, POCValKeyProposalTimeout,
ProposalGCWindowCheck, RandState, Ledger, Name, Itr, []),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
lager:debug("Selected POCs ~p", [POCSubset]),
lager:info("Selected ~p POCs for block height ~p", [length(POCSubset), BlockHeight]),

Expand Down Expand Up @@ -3602,7 +3602,7 @@ find_routing_via_devaddr(DevAddr0, Ledger) ->
{_Name, DB, SubnetCF} = subnets_cf(Ledger),
{ok, Itr} = rocksdb:iterator(DB, SubnetCF, []),
Dest = subnet_lookup(Itr, DevAddr, rocksdb:iterator_move(Itr, {seek_for_prev, <<DevAddr:25/integer-unsigned-big, ?BITS_23:23/integer>>})),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
case Dest of
error ->
{error, subnet_not_found};
Expand Down Expand Up @@ -3812,7 +3812,7 @@ allocate_subnet(Size, Ledger) ->
{_, DB, SubnetCF} = subnets_cf(Ledger),
{ok, Itr} = rocksdb:iterator(DB, SubnetCF, []),
Result = allocate_subnet(Size, Itr, rocksdb:iterator_move(Itr, first), none),
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Result.

allocate_subnet(Size, _Itr, {error, invalid_iterator}, none) ->
Expand Down Expand Up @@ -4370,7 +4370,7 @@ rocks_fold(Ledger, DB, CF, Opts0, Fun, Acc) ->
%% catch _:_ ->
%% Acc
after
?ITERATOR_CLOSE(Itr)
?ROCKSDB_ITERATOR_CLOSE(Itr)
end.

mk_cache_fold_fun(Cache, CF, Start, End, Fun) ->
Expand Down
2 changes: 1 addition & 1 deletion src/state_channel/blockchain_state_channels_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ state_channels(#state{db=DB, cf=CF}) ->
state_channels(Itr, rocksdb:iterator_move(Itr, first), []).

state_channels(Itr, {error, invalid_iterator}, Acc) ->
?ITERATOR_CLOSE(Itr),
?ROCKSDB_ITERATOR_CLOSE(Itr),
Acc;
state_channels(Itr, {ok, _, SCBin}, Acc) ->
state_channels(Itr, rocksdb:iterator_move(Itr, next), [binary_to_term(SCBin)|Acc]).
Expand Down

0 comments on commit 7cd8b38

Please sign in to comment.