Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

Commit

Permalink
inline first_fold to make Db reachable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Newson committed May 2, 2011
1 parent b71b57c commit 3274505
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mem3_nodes.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ code_change(_OldVsn, State, _Extra) ->
initialize_nodelist() ->
DbName = couch_config:get("mem3", "node_db", "nodes"),
{ok, Db} = mem3_util:ensure_exists(DbName),
{ok, _, Nodes0} = couch_btree:fold(Db#db.id_tree, fun first_fold/3, [], []),
{ok, _, Nodes0} = couch_btree:fold(Db#db.id_tree,
fun(#full_doc_info{id = <<"_design/", _/binary>>}, _, Acc) ->
{ok, Acc};
(#full_doc_info{deleted=true}, _, Acc) ->
{ok, Acc};
(#full_doc_info{id=Id}, _, Acc) ->
{ok, [mem3_util:to_atom(Id) | Acc]}
end, [], []),
% add self if not already present
case lists:member(node(), Nodes0) of
true ->
Expand All @@ -85,13 +92,6 @@ initialize_nodelist() ->
couch_db:close(Db),
{lists:sort(Nodes), Db#db.update_seq}.

first_fold(#full_doc_info{id = <<"_design/", _/binary>>}, _, Acc) ->
{ok, Acc};
first_fold(#full_doc_info{deleted=true}, _, Acc) ->
{ok, Acc};
first_fold(#full_doc_info{id=Id}, _, Acc) ->
{ok, [mem3_util:to_atom(Id) | Acc]}.

listen_for_changes(Since) ->
DbName = couch_config:get("mem3", "node_db", "nodes"),
{ok, Db} = mem3_util:ensure_exists(DbName),
Expand Down

0 comments on commit 3274505

Please sign in to comment.