wjzz avatar wjzz committed 89378d9 Draft

Less noise in the console.

Comments (0)

Files changed (4)

Erlang/metadata.erl

 
 %% single file example
 ex() ->
-    {ok, Content} = file:read_file("data/bb.torrent"),
-    %% {ok, Content} = file:read_file("data/java.torrent"),
+    %% {ok, Content} = file:read_file("data/bb.torrent"),
+    {ok, Content} = file:read_file("data/java.torrent"),
 %%    {ok, Content} = file:read_file("data/immortal.torrent"),
     Content.
 
 %% request
 parse_peer_msg(13, Peer, PeerPid, Socket, MetaInfo) ->
     {ok, <<6:8,Index:32,Begin:32,Length:32>>} = gen_tcp:recv(Socket, 13),
-    io:format("Request: ~p/~p+~p~n", [Index,Begin,Length]),
+    %% io:format("Request: ~p/~p+~p~n", [Index,Begin,Length]),
 
     %% TODO: inform the requster about this request
 
 
 handle_msg({piece_completed, PieceNo}, State) ->
     {Host, _} = State#state.peer,
-    io:format("Peer ~p finished #~p~n",
-              [pretty_ip(Host), PieceNo]),
-
+    %% io:format("Peer ~p finished #~p~n",
+    %%           [pretty_ip(Host), PieceNo]),
+    %% 
     %%waiting = State#state.my_status,
     
     State;

Erlang/pieces.erl

     %%DoneNum = length(Finished),
     DoneNum = ets:info(Finished, size),
     Percentage = (100 * DoneNum) / PiecesNum,
-    io:format("Finished ~p/~p pieces (~.2f%).~n",
-              [DoneNum, 
-               PiecesNum,
-               Percentage]),
+    %% io:format("Finished ~p/~p pieces (~.2f%).~n",
+    %%           [DoneNum, 
+    %%            PiecesNum,
+    %%            Percentage]),
 
     case PiecesNum == DoneNum of
         false -> ok;
              State#state{piece_dict = UpdatedPieceDict}};
         
         {all_parts, PieceBinary} ->
-            io:format("We got all blocks of #~p!~n",
-                     [PartNo]),
+            %% io:format("We got all blocks of #~p!~n",
+            %%          [PartNo]),
             
             case check_piece_hash(State#state.meta_data, 
                                   PartNo, 
             wrong_hash;
 
         true ->
-            io:format("Piece #~p has GOOD hash.~n",
-                      [PartNo]),
+            %% io:format("Piece #~p has GOOD hash.~n",
+            %%           [PartNo]),
             ok
     end.
 

Erlang/torrent.erl

     start(9999).
 
 start(MonitorPortNo) ->
-    download_torrent(MonitorPortNo, metadata:single()).
+    download_torrent(MonitorPortNo, metadata:multi()).
 
 close() ->
     io:format("Stopping the download!~n"),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.