get_subnodes(Host, NodeID, _From) ->
get_subnodes(Host, NodeID).
+get_subnodes(Host, <<>>) ->
+ get_subnodes_helper(Host, <<>>);
get_subnodes(Host, NodeID) ->
case find_node(Host, NodeID) of
false -> {error, ?ERR_ITEM_NOT_FOUND};
- _ ->
- Q = qlc:q([Node || #pubsub_node{nodeid = {NHost, _},
- parents = Parents} = Node <- mnesia:table(pubsub_node),
- Host == NHost,
- lists:member(NodeID, Parents)]),
- qlc:e(Q)
+ _ -> get_subnodes_helper(Host, NodeID)
end.
+get_subnodes_helper(Host, NodeID) ->
+ Q = qlc:q([Node || #pubsub_node{nodeid = {NHost, _},
+ parents = Parents} = Node <- mnesia:table(pubsub_node),
+ Host == NHost,
+ lists:member(NodeID, Parents)]),
+ qlc:e(Q).
+
get_subnodes_tree(Host, NodeID, From) ->
Pred = fun (NID, #pubsub_node{parents = Parents}) ->
lists:member(NID, Parents)
true;
validate_parentage(Key, Owners, [[] | T]) ->
validate_parentage(Key, Owners, T);
+validate_parentage(Key, Owners, [<<>> | T]) ->
+ validate_parentage(Key, Owners, T);
validate_parentage(Key, Owners, [ParentID | T]) ->
case find_node(Key, ParentID) of
false -> {error, ?ERR_ITEM_NOT_FOUND};