anchor.diff:  -module(bkdcore_rpc).
   -behaviour(gen_server).
   -include("bkdcore.hrl").
  +-compile([{parse_transform, lager_transform}]).
   % API
   -export([call/2,cast/2,async_call/3,multicall/2,is_connected/1]).
   % gen_server
  
positive.code: handle_cast(_, P) ->
  	{noreply, P}.
  
  handle_info({tcp,_S,<<Key:40/binary,Rem/binary>>},#dp{direction = receiver,isinit = false} = P) ->
  	Key = bkdcore:rpccookie(),
  	inet:setopts(P#dp.sock,[{active, once}]),
  	case Rem of
  		<<>> ->
  			{noreply,P#dp{isinit = true}};
  		<<"tunnel",Mod/binary>> ->
  			{noreply,P#dp{direction = tunnel, isinit = true, permanent = true, 
  						  tunnelmod = binary_to_existing_atom(Mod,latin1)}}
  	end;
  handle_info({tcp,_,Bin},#dp{direction = tunnel} = P) ->
  	apply(P#dp.tunnelmod,tunnel_bin,[Bin]),
  	inet:setopts(P#dp.sock,[{active, once}]),
  	{noreply,P};
  handle_info({tcp,_,<<Id:24/unsigned,SizeAndBody/binary>>},P) ->
  	case get(Id) of
  		undefined ->
  
negative.code: init([{From,FromRef},Node]) ->
  	case distreg:reg({bkdcore,Node}) of
  		ok ->
  			case bkdcore:node_address(Node) of
  				{IP,Port} ->
  					case gen_tcp:connect(IP,Port,[{packet,4},{keepalive,true},binary,{active,once},
  													{send_timeout,2000},{nodelay,true}],2000) of
  						{ok,S} ->
  							ok = gen_tcp:send(S,bkdcore:rpccookie(Node)),
  							erlang:send_after(5000,self(),timeout),
  							{ok, #dp{sock = S, direction = sender, connected_to = Node}};
  						_Err ->
  							erlang:send_after(1000,self(),reconnect),
  							{ok,#dp{direction = sender, connected_to = Node}}
  					end;
  				undefined ->
  					lager:error("Node address does not exist ~p",[Node]),
  					{stop,invalidnode}
  			end;
  		name_exists ->
  			From ! {FromRef,name_exists},
  