mldonkey-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-commits] mldonkey configMakefile.in distrib/ChangeLog sr...


From: mldonkey-commits
Subject: [Mldonkey-commits] mldonkey configMakefile.in distrib/ChangeLog sr...
Date: Sun, 11 Jun 2006 17:37:39 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       06/06/11 17:37:39

Modified files:
        config         : Makefile.in 
        distrib        : ChangeLog 
        src/daemon/common: commonFile.ml commonFile.mli commonGlobals.ml 
                           commonSwarming.ml guiDecoding.ml 
                           guiEncoding.ml guiTypes.ml 
        src/daemon/driver: driverInteractive.ml 
        src/gtk2/gui   : guiArt.ml guiArt.mli guiMisc.ml guiTypes2.ml 
        src/networks/bittorrent: bTClients.ml bTGlobals.ml 
                                 bTInteractive.ml 
        src/networks/donkey: donkeyClient.ml donkeyInteractive.ml 
                             donkeyOneFile.ml donkeyShare.ml 
        src/networks/fileTP: fileTPInteractive.ml 
        src/networks/gnutella: gnutellaInteractive.ml 

Log message:
        patch #5168

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/config/Makefile.in?cvsroot=mldonkey&r1=1.160&r2=1.161
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.877&r2=1.878
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonFile.ml?cvsroot=mldonkey&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonFile.mli?cvsroot=mldonkey&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonGlobals.ml?cvsroot=mldonkey&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonSwarming.ml?cvsroot=mldonkey&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiDecoding.ml?cvsroot=mldonkey&r1=1.55&r2=1.56
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiEncoding.ml?cvsroot=mldonkey&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiTypes.ml?cvsroot=mldonkey&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverInteractive.ml?cvsroot=mldonkey&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/gtk2/gui/guiArt.ml?cvsroot=mldonkey&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/gtk2/gui/guiArt.mli?cvsroot=mldonkey&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/gtk2/gui/guiMisc.ml?cvsroot=mldonkey&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/gtk2/gui/guiTypes2.ml?cvsroot=mldonkey&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTClients.ml?cvsroot=mldonkey&r1=1.72&r2=1.73
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTGlobals.ml?cvsroot=mldonkey&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTInteractive.ml?cvsroot=mldonkey&r1=1.95&r2=1.96
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyClient.ml?cvsroot=mldonkey&r1=1.93&r2=1.94
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyInteractive.ml?cvsroot=mldonkey&r1=1.108&r2=1.109
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyOneFile.ml?cvsroot=mldonkey&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyShare.ml?cvsroot=mldonkey&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/fileTP/fileTPInteractive.ml?cvsroot=mldonkey&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/gnutella/gnutellaInteractive.ml?cvsroot=mldonkey&r1=1.57&r2=1.58

Patches:
Index: config/Makefile.in
===================================================================
RCS file: /sources/mldonkey/mldonkey/config/Makefile.in,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -b -r1.160 -r1.161
--- config/Makefile.in  6 Jun 2006 22:32:44 -0000       1.160
+++ config/Makefile.in  11 Jun 2006 17:37:38 -0000      1.161
@@ -191,7 +191,8 @@
   $(LIB)/gettext.ml4 $(LIB)/md5_c.c $(LIB)/sha1_c.c \
   $(LIB)/tiger.c \
   $(LIB)/stubs_c.c  $(LIB)/set2.ml $(LIB)/queues.ml \
-  $(LIB)/charsetstubs.c $(LIB)/charset.ml
+  $(LIB)/charsetstubs.c $(LIB)/charset.ml \
+  $(LIB)/verificationBitmap.ml
 
 ifeq ("$(MAGIC)", "yes")
   MAGIC_LIBS_flags += -cclib -lmagic

Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.877
retrieving revision 1.878
diff -u -b -r1.877 -r1.878
--- distrib/ChangeLog   11 Jun 2006 17:32:27 -0000      1.877
+++ distrib/ChangeLog   11 Jun 2006 17:37:38 -0000      1.878
@@ -15,6 +15,7 @@
 =========
 
 2006/06/11
+5168: Global module to abstract verification bitmaps (pango)
 5167: Swarmer: Fix saving ini data for merged downloads (pango)
 5166: Swarmer: New module to abstract verification bitmaps (pango)
 

Index: src/daemon/common/commonFile.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonFile.ml,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- src/daemon/common/commonFile.ml     6 Jun 2006 22:31:18 -0000       1.54
+++ src/daemon/common/commonFile.ml     11 Jun 2006 17:37:38 -0000      1.55
@@ -510,7 +510,7 @@
 
 (* Use span for Opera DOM compatibility *)
 let colored_chunks chunks =
-  let chunks_length = Array.length chunks in
+  let chunks_length = VerificationBitmap.length chunks in
   let graph_width = min !!html_vd_chunk_graph_max_width (8 * chunks_length) in
   let ostr = Buffer.create 100 in
   Printf.bprintf ostr "\\<table cellspacing=0 cellpadding=0 
width=\\\"%dpx\\\"\\>\\<tr\\>" graph_width;
@@ -527,34 +527,39 @@
       current_output_bit := new_output_bit
     end in
 
-  (match !!html_vd_chunk_graph_style with
+  (let color_of_state = function
+    | VerificationBitmap.State_missing -> 0
+    | VerificationBitmap.State_partial -> 1
+    | VerificationBitmap.State_complete -> 2
+    | VerificationBitmap.State_verified -> 3 in
+    match !!html_vd_chunk_graph_style with
      | 0 ->
-        let previous = ref 0 in
+        let previous = ref VerificationBitmap.State_missing in
         let runlength = ref 0 in
 
-        Array.iter (fun b ->
+        VerificationBitmap.iteri (fun _ b ->
           if b = !previous then
             incr runlength
           else begin
-            display_bar !previous !runlength;
+            if !runlength > 0 then
+              display_bar (color_of_state !previous) !runlength;
             previous := b;
             runlength := 1
           end
         ) chunks;
-        display_bar !previous !runlength
+        display_bar (color_of_state !previous) !runlength
      | _ ->
         let missing = ref 0 in
         let partial = ref 0 in
         let complete = ref 0 in
         let verified = ref 0 in
 
-        Array.iter (fun b -> 
+        VerificationBitmap.iteri (fun _ b -> 
           match b with
-             | 0 -> incr missing
-             | 1 -> incr partial
-             | 2 -> incr complete
-             | 3 -> incr verified
-             | _ -> ()
+             | VerificationBitmap.State_missing -> incr missing
+             | VerificationBitmap.State_partial -> incr partial
+             | VerificationBitmap.State_complete -> incr complete
+             | VerificationBitmap.State_verified -> incr verified
         ) chunks;
         match !!html_vd_chunk_graph_style with
           | 1 ->
@@ -608,33 +613,35 @@
 
       Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
 
-      let tt = ref "0=Missing, 1=Partial, 2=Complete, 3=Verified" in
-      let tc = String.length info.G.file_chunks in
+      (match info.G.file_chunks with 
+      | None -> ()
+      | Some chunks ->
+         let tt = "0=Missing, 1=Partial, 2=Complete, 3=Verified" in
+         let tc = VerificationBitmap.length chunks in
       let c0 = ref 0 in
       let c1 = ref 0 in
       let c2 = ref 0 in
       let c3 = ref 0 in   
 
-      String.iter (fun c ->
+         VerificationBitmap.iteri (fun _ c ->
         match c with
-        | '0' -> incr c0
-        | '1' -> incr c1
-        | '2' -> incr c2
-        | '3' -> incr c3
-        | _ -> ()
-      ) info.G.file_chunks;
+            | VerificationBitmap.State_missing -> incr c0
+            | VerificationBitmap.State_partial -> incr c1
+            | VerificationBitmap.State_complete -> incr c2
+            | VerificationBitmap.State_verified -> incr c3
+         ) chunks;
       
       let header = Printf.sprintf "%d (%d+%d+%d+%d): " tc !c0 !c1 !c2 !c3 in
 
       html_mods_td buf [
-        (!tt, "sr br", "Chunks");
-        (!tt, "sr", 
+            (tt, "sr br", "Chunks");
+            (tt, "sr", 
           header ^ if !!html_vd_chunk_graph then
-          (colored_chunks (Array.init (String.length info.G.file_chunks)
-          (fun i -> ((int_of_char info.G.file_chunks.[i])-48))))
+              colored_chunks chunks
           else
-            info.G.file_chunks
-        ) ];
+              VerificationBitmap.to_string chunks
+            ) ]
+      );
 
       (match file_magic file with
         Some magic ->
@@ -662,7 +669,10 @@
         (Int64.to_string info.G.file_size)
         (Int64.to_string info.G.file_downloaded)
         (file_priority file);
-      Printf.bprintf buf "Chunks: [%-s]\n" info.G.file_chunks;
+      Printf.bprintf buf "Chunks: [%-s]\n"
+       (match info.G.file_chunks with
+       | None -> ""
+       | Some chunks -> VerificationBitmap.to_string chunks);
       (match impl.impl_file_probable_name with
           None -> ()
         | Some filename ->
@@ -1036,7 +1046,7 @@
     T.file_all_sources = 0;
     T.file_active_sources = 0;
     T.file_sources = None;
-    T.file_chunks = "";
+    T.file_chunks = None;
     T.file_availability = [];
     T.file_format = FormatNotComputed 0;
     T.file_chunks_age = [||];

Index: src/daemon/common/commonFile.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonFile.mli,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- src/daemon/common/commonFile.mli    6 Jun 2006 22:31:18 -0000       1.15
+++ src/daemon/common/commonFile.mli    11 Jun 2006 17:37:38 -0000      1.16
@@ -102,7 +102,7 @@
 val file_download_rate : 'a file_impl -> float
 val add_file_downloaded : CommonTypes.file -> Int64.t -> unit
 val file_downloaders : CommonTypes.file -> CommonTypes.ui_conn -> int -> bool
-val colored_chunks : int array -> string
+val colored_chunks : VerificationBitmap.t -> string
 val file_print : CommonTypes.file -> CommonTypes.ui_conn -> unit
 val file_size : CommonTypes.file -> int64
 val file_disk_name : CommonTypes.file -> string

Index: src/daemon/common/commonGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonGlobals.ml,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- src/daemon/common/commonGlobals.ml  23 May 2006 17:39:01 -0000      1.66
+++ src/daemon/common/commonGlobals.ml  11 Jun 2006 17:37:38 -0000      1.67
@@ -710,8 +710,10 @@
 
 let partial_chunk c =
   match c with
-    '0' | '1' -> true
-  | _ -> false
+  | VerificationBitmap.State_missing | VerificationBitmap.State_partial -> 
+      true
+  | VerificationBitmap.State_complete | VerificationBitmap.State_verified -> 
+      false
 
 module Connections = struct
 

Index: src/daemon/common/commonSwarming.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonSwarming.ml,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- src/daemon/common/commonSwarming.ml 11 Jun 2006 17:32:27 -0000      1.40
+++ src/daemon/common/commonSwarming.ml 11 Jun 2006 17:37:38 -0000      1.41
@@ -87,72 +87,6 @@
 open CommonTypes
 open CommonClient
 
-module VerificationBitmap : (sig
-  type t
-  type part_state = 
-    State_missing | State_partial | State_complete | State_verified
-
-  val create : int -> part_state -> t
-  val get : t -> int -> part_state
-  val set : t -> int -> part_state -> unit
-  val length : t -> int
-
-  val iter : (int -> part_state -> unit) -> t -> unit
-  val existsi : (int -> part_state -> bool) -> t -> bool
-  val for_all : (part_state -> bool) -> t -> bool
-
-  val to_string : t -> string
-  val of_string : string -> t
-  val state_to_char : part_state -> char
-end) 
-  = (struct
-    type t = string
-    type part_state = 
-      State_missing | State_partial | State_complete | State_verified
-
-    let state_to_char = function
-      | State_missing -> '0'
-      | State_partial -> '1'
-      | State_complete -> '2'
-      | State_verified -> '3'
-
-    let char_to_state = function
-      | '0' -> State_missing
-      | '1' -> State_partial
-      | '2' -> State_complete
-      | '3' -> State_verified 
-      | _ -> assert false
-
-    let create n c = String.make n (state_to_char c)
-    let get x i = (char_to_state x.[i])
-    let set x i c = x.[i] <- state_to_char c
-    let length = String.length
-
-    let to_string x = x
-    let of_string x = x
-
-    let iter f x = 
-      let l = String.length x in
-      let rec aux i =
-       if i < l then begin
-         f i (char_to_state x.[i]);
-         aux (i+1)
-       end in
-      aux 0
-
-    let existsi p x = 
-      let l = String.length x in
-      let rec aux i =
-       i < l && (p i (char_to_state x.[i]) || aux (i+1)) in
-      aux 0
-
-    let for_all p s =
-      let l = String.length s in
-      let rec aux i =
-        i >= l || p (char_to_state s.[i]) && aux (i+1) in
-      aux 0
-  end)
-
 module VB = VerificationBitmap
 
 (* If we want to become 'multinet', we should:
@@ -435,7 +369,7 @@
 
 let compute_last_seen t =
   let last_seen_total = ref (BasicSocket.last_time ()) in
-  VB.iter (fun i c -> 
+  VB.iteri (fun i c -> 
     if c = VB.State_verified then
       t.t_last_seen.(i) <- BasicSocket.last_time ()
     else
@@ -1380,7 +1314,7 @@
   | VB.State_verified -> ()
 
 let set_chunks_verified_bitmap t bitmap =
-  VB.iter (fun j c ->
+  VB.iteri (fun j c ->
     match c with
     | VB.State_missing | VB.State_partial -> 
        ()
@@ -1393,7 +1327,7 @@
   ) bitmap
 
 let chunks_verified_bitmap t = 
-    VB.to_string t.t_converted_verified_bitmap
+    t.t_converted_verified_bitmap
 
 (** Check the equality of the hash of [t]'s data between offsets
     [begin_pos] and [end_pos] against the value of [uid] *)
@@ -1441,11 +1375,11 @@
           try
             let s = t.t_s in
             if verify t chunks.(0) zero s.s_size then
-             VB.iter (fun j _ ->
+             VB.iteri (fun j _ ->
                set_frontend_bitmap_3 t j
              ) t.t_converted_verified_bitmap
            else
-             VB.iter (fun j c ->
+             VB.iteri (fun j c ->
                if c = VB.State_complete then set_frontend_bitmap_0 t j
              ) t.t_converted_verified_bitmap
           with VerifierNotReady -> ()
@@ -1460,20 +1394,20 @@
 
 let verify_all_chunks t =
   let s = t.t_s in
-  VB.iter (fun i _ -> must_verify_block s i) s.s_verified_bitmap
+  VB.iteri (fun i _ -> must_verify_block s i) s.s_verified_bitmap
 
 (** same, and synchronously calls the verification of all chunks *)
 
 let verify_all_chunks_immediately t =
   verify_all_chunks t;
-  VB.iter (fun i _ -> verify_chunk t i) t.t_converted_verified_bitmap
+  VB.iteri (fun i _ -> verify_chunk t i) t.t_converted_verified_bitmap
     
 
 (** synchronously verify all completed chunks not yet verified *)
 
 let compute_bitmap t =
   if t.t_ncomplete_chunks > t.t_nverified_chunks then 
-    VB.iter (fun i c -> 
+    VB.iteri (fun i c -> 
       if c = VB.State_complete then verify_chunk t i) 
t.t_converted_verified_bitmap
 
 
@@ -3035,7 +2969,7 @@
   [("file_primary", bool_to_value t.t_primary);
    ("file_swarmer", string_to_value t.t_s.s_filename);
    ("file_mtime", float_to_value (try file_mtime t.t_file with _ -> 0.));
-   ("file_chunks", string_to_value (chunks_verified_bitmap t))] @
+   ("file_chunks", string_to_value (VB.to_string (chunks_verified_bitmap t)))] 
@
   (if t.t_primary then
     [("file_present_chunks", List
       (List.map (fun (i1,i2) ->
@@ -3206,7 +3140,7 @@
     | tprim :: tail ->
         assert(tprim.t_primary);
 
-       VB.iter (fun i c ->
+       VB.iteri (fun i c ->
            if c = VB.State_verified then begin
              if List.exists (fun j -> VB.get s.s_verified_bitmap j <> 
VB.State_verified) 
                tprim.t_blocks_of_chunk.(i) then
@@ -3223,7 +3157,7 @@
           assert (not t.t_primary);
           assert (file_fd t.t_file == fd);
          
-         VB.iter (fun i c ->
+         VB.iteri (fun i c ->
            if c = VB.State_verified then begin
              if List.exists (fun j -> VB.get s.s_verified_bitmap j <> 
VB.State_verified)
                t.t_blocks_of_chunk.(i) then

Index: src/daemon/common/guiDecoding.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiDecoding.ml,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- src/daemon/common/guiDecoding.ml    17 May 2006 08:52:43 -0000      1.55
+++ src/daemon/common/guiDecoding.ml    11 Jun 2006 17:37:38 -0000      1.56
@@ -595,7 +595,10 @@
     file_all_sources = file_all_sources;
     file_active_sources = file_active_sources;
     file_state = state;
-    file_chunks = chunks;
+    file_chunks = 
+      if chunks <> "" then 
+       Some (VerificationBitmap.of_string chunks)
+      else None;
     file_availability = availability;
     file_download_rate = rate;
     file_chunks_age = chunks_age;

Index: src/daemon/common/guiEncoding.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiEncoding.ml,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- src/daemon/common/guiEncoding.ml    30 May 2006 10:56:09 -0000      1.54
+++ src/daemon/common/guiEncoding.ml    11 Jun 2006 17:37:38 -0000      1.55
@@ -438,7 +438,9 @@
     end;
   if f.file_fields.Fields_file_info.file_chunks then begin
       buf_int8 buf 9;
-      buf_string buf f.file_chunks;  
+    buf_string buf (match f.file_chunks with
+    | None -> ""
+    | Some chunks -> VerificationBitmap.to_string chunks);  
     end;
   if f.file_fields.Fields_file_info.file_availability then begin
       buf_int8 buf 10;
@@ -556,7 +558,9 @@
   buf_int buf f.file_all_sources;  
   buf_int buf f.file_active_sources;  
   buf_file_state proto buf f.file_state;  
-  buf_string buf f.file_chunks;  
+  buf_string buf (match f.file_chunks with
+  | None -> ""
+  | Some chunks -> VerificationBitmap.to_string chunks);  
   if proto > 17 then
     buf_list buf (fun buf (network, avail) ->
         buf_int buf network;

Index: src/daemon/common/guiTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiTypes.ml,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- src/daemon/common/guiTypes.ml       12 May 2006 21:08:30 -0000      1.27
+++ src/daemon/common/guiTypes.ml       11 Jun 2006 17:37:38 -0000      1.28
@@ -132,7 +132,7 @@
     mutable file_active_sources : int; (* MANY CHANGES *)
     mutable file_all_sources : int;
     mutable file_state : file_state;
-    mutable file_chunks : string;
+    mutable file_chunks : VerificationBitmap.t option;
     mutable file_availability : (int * string) list; (* MANY CHANGES *)
     mutable file_sources : int list option;
     mutable file_download_rate : float; (* LOT OF CHANGES *)
@@ -323,7 +323,7 @@
     file_state = FileDownloading;
     file_sources = None;
     file_download_rate = 2.2;
-    file_chunks = "1010100";
+    file_chunks = Some (VerificationBitmap.of_string "1010100");
     file_downloaded = Int64.of_string "68758764";
     file_availability = [0,""];
     file_format = FormatUnknown;

Index: src/daemon/driver/driverInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- src/daemon/driver/driverInteractive.ml      6 Jun 2006 22:31:18 -0000       
1.81
+++ src/daemon/driver/driverInteractive.ml      11 Jun 2006 17:37:38 -0000      
1.82
@@ -38,6 +38,8 @@
 open CommonTypes
 open Int64ops
 
+module VB = VerificationBitmap
+
 let log_prefix = "[dIve]"
 
 let lprintf_nl fmt =
@@ -159,6 +161,9 @@
 let file_availability f =
   match f.file_availability with
     (_,avail) :: _ ->
+      (match f.file_chunks with
+      | None -> 0.
+      | Some chunks ->
       let rec loop i p n =
         if i < 0
         then
@@ -166,14 +171,14 @@
           then 0.0
           else (p /. n *. 100.0)
         else
-        if partial_chunk f.file_chunks.[i]
+              if partial_chunk (VB.get chunks i)
         then
           if avail.[i] <> (char_of_int 0)
           then loop (i - 1) (p +. 1.0) (n +. 1.0)
           else loop (i - 1) p (n +. 1.0)
         else loop (i - 1) p n
       in
-      loop ((String.length avail) - 1) 0.0 0.0
+         loop ((String.length avail) - 1) 0.0 0.0)
   | _ -> 0.0
 
 let string_availability s =
@@ -852,7 +857,13 @@
     (Printf.sprintf "%5.1f%s" (Int64.to_float size /. 1073741824.) ("gb") )
   else if size < Int64.zero then
     (Printf.sprintf "%d chunks"
-    ((String.length file.file_chunks)-(String.length (String2.replace 
(String2.replace file.file_chunks '0' "") '1' ""))))
+      (match file.file_chunks with
+      | None -> 0
+      | Some chunks -> 
+         VB.fold_lefti (fun acc _ s -> match s with
+           | VB.State_missing | VB.State_partial -> acc
+           | VB.State_complete | VB.State_verified -> acc + 1
+         ) 0 chunks))
   else (Printf.sprintf "%8s%s" (Int64.to_string size) ("b") ) )
 
 let simple_print_file_list finished buf files format =

Index: src/gtk2/gui/guiArt.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/gtk2/gui/guiArt.ml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- src/gtk2/gui/guiArt.ml      14 Nov 2005 18:25:43 -0000      1.7
+++ src/gtk2/gui/guiArt.ml      11 Jun 2006 17:37:38 -0000      1.8
@@ -22,6 +22,7 @@
 
 module O = GuiOptions
 module M = GuiMessages
+module VB = VerificationBitmap
 
 let (!!) = Options.(!!)
 let (=:=) = Options.(=:=)
@@ -349,7 +350,7 @@
 (*                                                                             
   *)
 
(**********************************************************************************)
 
-let (avail_bars : ((string * string * bool), GdkPixbuf.pixbuf) Hashtbl.t) = 
Hashtbl.create 103
+let (avail_bars : ((string * VB.t option * bool), GdkPixbuf.pixbuf) Hashtbl.t) 
= Hashtbl.create 103
 
 (* make a simple function to give a 3D effect *)
 let highlight range i =
@@ -454,7 +455,9 @@
 
 let get_availability_of availability chunks is_file =
   let height = 16 in
-  let nchunks = max 1 (String.length chunks) in
+  let nchunks = match chunks with
+    | None -> 1
+    | Some chunks -> max 1 (VB.length chunks) in
   let avail =
     if is_file
       then begin
@@ -466,43 +469,57 @@
   let key = (avail, chunks, is_file) in
   try
     Hashtbl.find avail_bars key
-  with _ ->
+  with Not_found ->
     begin
       (if !!verbose then lprintf' "Creating new availability bar\n");
       let dest = GdkPixbuf.create ~width:nchunks ~height ~has_alpha:true () in
       (try
+       match chunks with
+       | None -> ()
+       | Some chunks ->
         for i = 0 to (nchunks - 1) do
           if is_file
-            then if chunks.[i] >= '2'
-              then GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_green
-              else begin
+          then 
+           (match VB.get chunks i with
+           | VB.State_complete | VB.State_verified ->
+               GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 ~height 
~src_x:0 ~src_y:0 color_green
+           | VB.State_missing | VB.State_partial -> 
                 let h = int_of_char (avail.[i]) in
-                if h = 0
-                  then if chunks.[i] = '0'
-                    then GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 
~width:1 ~height ~src_x:0 ~src_y:0 color_red
-                    else GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 
~width:1 ~height ~src_x:0 ~src_y:0 color_orange
-                  else if chunks.[i] = '0'
-                    then begin
+               match h, VB.get chunks i with
+               | 0, VB.State_missing ->
+                   GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_red
+               | 0, _ ->
+                   GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_orange
+               | _, VB.State_missing ->
                       let color_blue = 
!color_blue_relative.(!!O.gtk_misc_availability_max - h) in
                       GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_blue
-                    end else GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 
~width:1 ~height ~src_x:0 ~src_y:0 color_yellow
-              end
-            else if int_of_char avail.[i] >= 49
-              then if chunks.[i] >= '2'
-                then GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_black
-                else if chunks.[i] = '0'
-                  then GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_green
-                  else GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_yellow
-              else GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_red
+               | _, _ ->
+                   GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 
~height ~src_x:0 ~src_y:0 color_yellow
+            )
+          else 
+           match int_of_char avail.[i] >= 49, VB.get chunks i with
+           | true, VB.State_complete
+           | true, VB.State_verified ->
+               GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 ~height 
~src_x:0 ~src_y:0 color_black
+           | true, VB.State_missing ->
+               GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 ~height 
~src_x:0 ~src_y:0 color_green
+           | true, VB.State_partial ->
+               GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 ~height 
~src_x:0 ~src_y:0 color_yellow
+           | false, _ ->
+               GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 ~height 
~src_x:0 ~src_y:0 color_red
           done;
 
       with _ ->
-        begin
-          (if !!verbose then lprintf' "Exception in creating avail_bar avail: 
%s chunks: %s file: %b\n" avail chunks is_file);
-          for i = 0 to (nchunks - 1) do
+          if !!verbose then 
+           lprintf' "Exception in creating avail_bar avail: %s chunks: %s 
file: %b\n" 
+             avail 
+             (match chunks with
+             | None -> ""
+             | Some chunks -> VB.to_string chunks) 
+             is_file;
+          for i = 0 to nchunks - 1 do
             GdkPixbuf.copy_area ~dest ~dest_x:i ~dest_y:0 ~width:1 ~height 
~src_x:0 ~src_y:0 color_grey
-          done
-        end);
+          done);
     Hashtbl.add avail_bars key dest;
     dest
   end

Index: src/gtk2/gui/guiArt.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/gtk2/gui/guiArt.mli,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/gtk2/gui/guiArt.mli     13 May 2005 21:15:47 -0000      1.2
+++ src/gtk2/gui/guiArt.mli     11 Jun 2006 17:37:38 -0000      1.3
@@ -28,6 +28,6 @@
 
 val create_color_blue_relative : unit -> unit
 
-val get_availability_of : string -> string -> bool -> GdkPixbuf.pixbuf
+val get_availability_of : string -> VerificationBitmap.t option -> bool -> 
GdkPixbuf.pixbuf
 
-val clean_avail_bars : (string * string * bool) list -> unit
+val clean_avail_bars : (string * VerificationBitmap.t option * bool) list -> 
unit

Index: src/gtk2/gui/guiMisc.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/gtk2/gui/guiMisc.ml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- src/gtk2/gui/guiMisc.ml     9 Jan 2006 00:33:13 -0000       1.16
+++ src/gtk2/gui/guiMisc.ml     11 Jun 2006 17:37:38 -0000      1.17
@@ -33,6 +33,7 @@
 module A = GuiArt
 module U = GuiUtf8
 module G = GuiGlobal
+module VB = VerificationBitmap
 
 let (!!) = Options.(!!)
 let (=:=) = Options.(=:=)
@@ -751,17 +752,20 @@
 (*************************************************************************)
 
 let chunks_to_string chunks =
-  let len = String.length chunks in
-  Printf.sprintf "%d" len
+  match chunks with
+  | None -> "0"
+  | Some chunks -> string_of_int (VB.length chunks)
 
 let completed_chunks_to_string chunks =
-  let len = String.length chunks in
-  let p = ref 0 in
-  for i = 0 to len - 1 do
-    if chunks.[i] >= '2'
-      then (incr p)
-  done;
-  (Printf.sprintf "%d (%d" !p (!p * 100 / len)) ^ "%)"
+  match chunks with
+  | None -> "0"
+  | Some chunks ->
+      let len = VB.length chunks in
+      let p = VB.fold_lefti (fun acc _ s -> match s with
+       | VB.State_missing | VB.State_partial -> acc
+       | VB.State_complete | VB.State_verified -> acc + 1
+      ) 0 chunks in
+      Printf.sprintf "%d (%d%%)" p (p * 100 / len)
 
 (*************************************************************************)
 (*                                                                       *)
@@ -775,7 +779,7 @@
       let rec loop i =
         if i < 0
           then false
-          else if CommonGlobals.partial_chunk chunks.[i] &&
+        else if CommonGlobals.partial_chunk (VerificationBitmap.get chunks i) 
&&
                   availability.[i] <> (char_of_int 0)
             then true
             else loop (i - 1)
@@ -790,18 +794,18 @@
       !b
 
 let relative_availability_of avail chunks =
+  match chunks with
+  | None -> "0."
+  | Some chunks ->
   let rec loop i p n =
-    if i < 0
-      then if n = 0.
-        then "0." (* Watch out !! Don't modify, we have to keep a float format 
*)
-        else Printf.sprintf "%5.1f" (p /. n *. 100.)
-      else if CommonGlobals.partial_chunk chunks.[i]
-        then if avail.[i] <> (char_of_int 0)
-          then loop (i - 1) (p +. 1.) (n +. 1.)
-          else loop (i - 1) p (n +. 1.)
-        else loop (i - 1) p n
-  in
-  loop ((String.length avail) - 1) 0. 0.
+       if i < 0 then
+         if n = 0 then "0." (* Watch out !! Don't modify, we have to keep a 
float format *)
+         else Printf.sprintf "%5.1f" ((float p) /. (float n) *. 100.)
+       else 
+         loop (i - 1) 
+           (if CommonGlobals.partial_chunk (VerificationBitmap.get chunks i) 
then p + 1 else p)
+            (if avail.[i] <> (char_of_int 0) then n + 1 else n) in
+      loop ((String.length avail) - 1) 0 0
 
 
 let absolute_availability_of s =
@@ -834,19 +838,26 @@
     end else None
 
 let get_availability_bar_image avail chunks av_max is_file =
+  (match chunks with
+  | None -> 
   for i = 0 to String.length avail - 1 do
-    if chunks.[i] >= '2'
-      then avail.[i] <- char_of_int av_max
-      else if chunks.[i] = '0'
-        then begin
+       avail.[i] <- char_of_int (av_max - 1)
+      done
+  | Some chunks ->
+      for i = 0 to String.length avail - 1 do
+       avail.[i] <-
+         char_of_int (match VB.get chunks i with
+         | VB.State_complete | VB.State_verified ->
+             av_max
+         | VB.State_missing ->
           let avail_int =
-            if is_file
-              then int_of_char avail.[i]
+               if is_file then int_of_char avail.[i]
               else if int_of_char avail.[i] > 48 then 1 else 0
           in
-          avail.[i] <- char_of_int (min (av_max - 2) avail_int)
-        end else avail.[i] <- char_of_int (av_max - 1)
-  done;
+              min (av_max - 2) avail_int
+         | VB.State_partial ->
+             av_max - 1)
+      done);
   avail
 
 let sort_availability_bar (av1, chunks1) (av2, chunks2) is_file =

Index: src/gtk2/gui/guiTypes2.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/gtk2/gui/guiTypes2.ml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- src/gtk2/gui/guiTypes2.ml   27 Nov 2005 14:04:33 -0000      1.8
+++ src/gtk2/gui/guiTypes2.ml   11 Jun 2006 17:37:38 -0000      1.9
@@ -239,7 +239,7 @@
     mutable g_file_active_sources : int;
     mutable g_file_all_sources    : int;
     mutable g_file_state          : file_state;
-    mutable g_file_chunks         : string;
+    mutable g_file_chunks         : VerificationBitmap.t option;
     mutable g_file_availability   : (int * string) list;
     mutable g_file_sources        : int list option;
     mutable g_file_download_rate  : float;

Index: src/networks/bittorrent/bTClients.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTClients.ml,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- src/networks/bittorrent/bTClients.ml        7 Jun 2006 00:17:46 -0000       
1.72
+++ src/networks/bittorrent/bTClients.ml        11 Jun 2006 17:37:38 -0000      
1.73
@@ -64,6 +64,8 @@
 open BTStats
 open TcpMessages
 
+module VB = VerificationBitmap
+
 let http_ok = "HTTP 200 OK"
 let http11_ok = "HTTP/1.1 200 OK"
 
@@ -383,28 +385,31 @@
 (** Send a Bitfield message to a client.
   @param c The client to send the Bitfield message
 *)
-let send_bitfield c =
-  let bitmap =
-    match c.client_file.file_swarmer with
-      None ->
-(* This must be a seeded file... *)
-        String.make (Array.length c.client_file.file_chunks) '3'
-    | Some swarmer ->
-        CommonSwarming.chunks_verified_bitmap swarmer
-  in
 
-  if !verbose_download then lprintf_nl "Sending verified bitmap: [%s]" bitmap;
-
-(* In the future, only accept bitmap.[n] > '2' when verification works *)
+let send_bitfield c =
   send_client c (BitField
       (
-      let nchunks = String.length bitmap in
+      match c.client_file.file_swarmer with
+      | None ->
+         (* This must be a seeded file... *)
+         if !verbose_download then 
+           lprintf_nl "Sending completed verified bitmap";
+         let nchunks = Array.length c.client_file.file_chunks in
       let len = (nchunks+7)/8 in
       let s = String.make len '\000' in
       for i = 0 to nchunks - 1 do
-        if bitmap.[i] >= '2' then set_bit s i;
+           set_bit s i
       done;
       s
+      | Some swarmer ->
+         let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
+         if !verbose_download then 
+           lprintf_nl "Sending verified bitmap: [%s]" (VB.to_string bitmap);
+         let len = VB.length bitmap in
+         let s = String.make len '\000' in
+         VB.iteri (fun i c ->
+            if c = VB.State_verified then set_bit s i) bitmap;
+         s
     ))
 
 let counter = ref 0
@@ -906,13 +911,15 @@
                 disconnect_client c (Closed_for_error "Wrong bitfield length")
               end else begin
 
-                let verified = CommonSwarming.chunks_verified_bitmap swarmer in
+                let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
 
                 for i = 0 to npieces - 1 do
                   if is_bit_set p i then begin
                     c.client_new_chunks <- i :: c.client_new_chunks;
-                    if verified.[i] < '2' then
-                      c.client_interesting <- true;
+                    match VB.get bitmap i with
+                   | VB.State_missing | VB.State_partial ->
+                      c.client_interesting <- true
+                   | VB.State_complete | VB.State_verified -> ()
                   end 
                 done;
 
@@ -941,15 +948,16 @@
             None -> ()
           | Some swarmer ->
               let n = Int64.to_int n in
-              let verified = CommonSwarming.chunks_verified_bitmap swarmer in
-              (* lprintf_nl "verified: %c;" verified.[n]; *)
+              let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
+              (* lprintf_nl "verified: %c;" (VB.state_to_char (VB.get bitmap 
n)); *)
               (* if the peer has a chunk we don't, tell him we're interested 
and update his bitmap *)
-              if verified.[n] < '2' then begin
+             match VB.get bitmap n with
+             | VB.State_missing | VB.State_partial ->
                   c.client_interesting <- true;
                   send_interested c;
                   c.client_new_chunks <- n :: c.client_new_chunks;
                   update_client_bitmap c;
-                end;
+             | VB.State_complete | VB.State_verified -> ()
 
 (*        begin
           match c.client_bitmap, c.client_uploader with

Index: src/networks/bittorrent/bTGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTGlobals.ml,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- src/networks/bittorrent/bTGlobals.ml        25 May 2006 19:47:25 -0000      
1.59
+++ src/networks/bittorrent/bTGlobals.ml        11 Jun 2006 17:37:38 -0000      
1.60
@@ -156,7 +156,7 @@
         | Some b ->
             let chunk_num = CommonSwarming.block_chunk_num swarmer b in
             let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
-            bitmap.[chunk_num] <> '3')
+            VB.get bitmap chunk_num <> VB.State_verified)
     in
     if must_send then
       begin

Index: src/networks/bittorrent/bTInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTInteractive.ml,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -b -r1.95 -r1.96
--- src/networks/bittorrent/bTInteractive.ml    6 Jun 2006 22:31:18 -0000       
1.95
+++ src/networks/bittorrent/bTInteractive.ml    11 Jun 2006 17:37:38 -0000      
1.96
@@ -50,6 +50,8 @@
 let _s x = _s "BTInteractive" x
 let _b x = _b "BTInteractive" x
 
+module VB = VerificationBitmap
+
 exception Already_exists
 
 let op_file_all_sources file =
@@ -288,7 +290,7 @@
 
       let chunks = (match file.file_swarmer with
             None -> "" | Some swarmer ->
-              CommonSwarming.chunks_verified_bitmap swarmer) in
+              VB.to_string (CommonSwarming.chunks_verified_bitmap swarmer)) in
 
       let header_list = [
         ( "1", "srh br ac", "Client number", "Num" ) ;
@@ -320,8 +322,13 @@
         (fun i -> ((int_of_char info.G.file_chunks.[i])-48)))) ) ;
 *)
         ( "1", "srh ar", "Number of full chunks", (Printf.sprintf "%d"
-              (String.length (String2.replace
-                  (String2.replace chunks '0' "") '1' "")) )) 
+          (match file.file_swarmer with
+         | None -> 0
+         | Some swarmer ->
+             let bitmap = 
+               CommonSwarming.chunks_verified_bitmap swarmer in
+             VB.fold_lefti (fun acc _ s ->
+               if s = VB.State_verified then acc + 1 else acc) 0 bitmap)))
       ] in
 
       html_mods_table_header buf "sourcesTable" "sources al" header_list;
@@ -416,8 +423,8 @@
     P.file_network = network.network_num;
     P.file_names = [file.file_name, P.noips()];
     P.file_chunks = (match file.file_swarmer with
-        None -> "" | Some swarmer ->
-          CommonSwarming.chunks_verified_bitmap swarmer);
+    | None -> None 
+    | Some swarmer -> Some (CommonSwarming.chunks_verified_bitmap swarmer));
     P.file_availability =
     [network.network_num,(match file.file_swarmer with
           None -> "" | Some swarmer ->
@@ -450,7 +457,7 @@
     P.file_state = ft_state ft;
     P.file_sources = None;
     P.file_download_rate = 0.;
-    P.file_chunks = "";
+    P.file_chunks = None;
     P.file_availability =  [network.network_num, ""];
     P.file_format = FormatNotComputed 0;
     P.file_chunks_age = [| last_time () |];

Index: src/networks/donkey/donkeyClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyClient.ml,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -b -r1.93 -r1.94
--- src/networks/donkey/donkeyClient.ml 1 Jun 2006 01:40:28 -0000       1.93
+++ src/networks/donkey/donkeyClient.ml 11 Jun 2006 17:37:39 -0000      1.94
@@ -52,6 +52,8 @@
 open DonkeyReliability
 open DonkeyThieves
 
+module VB = VerificationBitmap
+
 let log_prefix = "[EDK]"
 
 let lprintf_nl fmt =
@@ -853,12 +855,12 @@
     None -> false
   | Some swarmer ->
       let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
-      let rec iter bitmap chunks i len =
-        if i = len then false else
-        if Bitv.get chunks i && bitmap.[i] < '2' then true else
-          iter bitmap chunks (i+1) len
-      in
-      iter bitmap chunks 0 (String.length bitmap)
+      VB.existsi (fun i s ->
+        Bitv.get chunks i && 
+         (match s with
+         | VB.State_missing | VB.State_partial -> true
+         | VB.State_complete | VB.State_verified -> false)
+      ) bitmap
     
 let received_client_bitmap c file chunks =
   
@@ -869,7 +871,7 @@
       match file.file_swarmer with
         None -> ()
       | Some swarmer ->
-          lprintf_nl "   %s" (CommonSwarming.chunks_verified_bitmap swarmer);
+          lprintf_nl "   %s" (VB.to_string 
(CommonSwarming.chunks_verified_bitmap swarmer));
     end;
   
   let chunks = 
@@ -1939,8 +1941,8 @@
                     Bitv.create file.file_nchunks true
               | Some swarmer ->
                   let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
-                  Bitv.init (String.length bitmap) 
-                      (fun i -> bitmap.[i] = '3')
+                  Bitv.init (VB.length bitmap) 
+                    (fun i -> VB.get bitmap i = VB.State_verified)
                   (* This is not very smart, as we might get banned for this 
request.
                      TODO We should probably check if we don't know already 
this source...
 
@@ -2532,8 +2534,8 @@
             | Some swarmer ->
                 let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
                 let chunks = 
-                  Bitv.init (String.length bitmap) 
-                  (fun i -> bitmap.[i] = '3')
+                  Bitv.init (VB.length bitmap) 
+                    (fun i -> VB.get bitmap i = VB.State_verified)
                 in
                 let ncompletesources = if extendedrequest > 1 then
                     0 else -1 in

Index: src/networks/donkey/donkeyInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -b -r1.108 -r1.109
--- src/networks/donkey/donkeyInteractive.ml    1 Jun 2006 01:40:28 -0000       
1.108
+++ src/networks/donkey/donkeyInteractive.ml    11 Jun 2006 17:37:39 -0000      
1.109
@@ -55,6 +55,7 @@
 open DonkeyStats
 open DonkeyUdp
 
+module VB = VerificationBitmap
 
 let result_name r =
   match r.result_names with
@@ -1028,8 +1029,8 @@
             P.file_active_sources = 
file.file_sources.DonkeySources.manager_active_sources;
             P.file_chunks = 
                   (match file.file_swarmer with
-                   | None -> "" 
-                   | Some swarmer -> CommonSwarming.chunks_verified_bitmap 
swarmer);
+                | None -> None
+                | Some swarmer -> Some (CommonSwarming.chunks_verified_bitmap 
swarmer));
             P.file_availability =
               [
                 network.network_num,
@@ -1292,8 +1293,8 @@
 
       let chunks =
       (match file.file_swarmer with
-       None -> "" | Some swarmer ->
-       CommonSwarming.chunks_verified_bitmap swarmer)
+      | None -> None 
+      | Some swarmer -> Some (CommonSwarming.chunks_verified_bitmap swarmer))
       in
 
       html_mods_table_header buf "sourcesTable" "sources al" ([
@@ -1326,12 +1327,16 @@
           ( "1", "srh ar br", "Connected time (minutes)", "CT" ) ;
           ( "0", "srh br", "Client MD4", "MD4" ) ;
           ( "0", "srh", "Chunks (absent|partial|present|verified)",
-            (colored_chunks
-                (Array.init (String.length chunks)
-                (fun i -> ((int_of_char chunks.[i])-48)))) ) ;
+         match chunks with
+         | None -> ""
+         | Some chunks -> colored_chunks chunks) ;
           ( "1", "srh ar", "Number of full chunks", (Printf.sprintf "%d"
-                (let fc = ref 0 in (String.iter (fun s -> if s = '3' then incr 
fc)
-                  chunks );!fc ))) ]);
+            (match chunks with
+           | None -> 0
+           | Some chunks ->
+               VerificationBitmap.fold_lefti (fun acc _ s ->
+                 if s = VerificationBitmap.State_verified then acc + 1
+                 else acc) 0 chunks))) ]);
 
 
       html_mods_cntr_init();
@@ -1409,8 +1414,12 @@
                   let _, qchunks,_ = List.find (fun (qfile, _,_) ->
                         qfile == file) qfiles in
                   let tc = ref 0 in
-                  let arr = Array.init (Bitv.length qchunks) 
-                              (fun i -> if Bitv.get qchunks i then begin incr 
tc; 2 end else 0) in
+                 let arr = 
+                   VerificationBitmap.init (Bitv.length qchunks) (fun i -> 
+                   if Bitv.get qchunks i then begin
+                     incr tc;
+                     VerificationBitmap.State_complete
+                   end else VerificationBitmap.State_missing) in
                   Printf.bprintf buf "%s\\</td\\>\\<td class=\\\"sr 
ar\\\"\\>%d\\</td\\>"
                     (CommonFile.colored_chunks arr) !tc;
                 with Not_found -> (

Index: src/networks/donkey/donkeyOneFile.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyOneFile.ml,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- src/networks/donkey/donkeyOneFile.ml        6 Jun 2006 23:50:51 -0000       
1.39
+++ src/networks/donkey/donkeyOneFile.ml        11 Jun 2006 17:37:39 -0000      
1.40
@@ -161,12 +161,7 @@
       | Some swarmer ->
           let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
 (*          lprintf "Verified bitmap: [%s]\n" bitmap; *)
-          let rec iter i =
-            if i =  String.length bitmap then true
-            else
-            if bitmap.[i] = '3' then iter (i+1) else false
-          in
-          let verified = iter 0 in
+         let verified = VB.for_all (( = ) VB.State_verified) bitmap in
           
           let downloaded = CommonSwarming.downloaded swarmer in
           if file_downloaded file <> downloaded then begin
@@ -191,14 +186,8 @@
             None -> ()
           | Some swarmer ->
               let bitmap = CommonSwarming.chunks_verified_bitmap swarmer in
-              let rec iter i len =
-                if i < len then
-                  if bitmap.[i] = '3' then
+             if VB.existsi (fun _ s -> s = VB.State_verified) bitmap then
                     DonkeyShare.must_share_file file
-                  else
-                    iter (i+1) len
-              in
-              iter 0 (String.length bitmap)
   ) files_by_md4
 
 let add_client_chunks c file client_chunks =

Index: src/networks/donkey/donkeyShare.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyShare.ml,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- src/networks/donkey/donkeyShare.ml  9 Jun 2006 22:20:18 -0000       1.47
+++ src/networks/donkey/donkeyShare.ml  11 Jun 2006 17:37:39 -0000      1.48
@@ -37,6 +37,8 @@
 open DonkeyComplexOptions
 open DonkeyGlobals
 
+module VB = VerificationBitmap
+
 let new_shared_files = ref []
 
 let must_share_file file codedname has_old_impl =
@@ -124,10 +126,11 @@
      * regardless of the mtime being set.)
      *)
     match file.file_swarmer with
-      Some s -> (let len = Array.length md4s in
-     let ver_str = String.make len '3' in
+    | Some s -> 
+       let len = Array.length md4s in
+       let ver_str = String.make len (VB.state_to_char VB.State_verified) in
      CommonSwarming.set_chunks_verified_bitmap s
-       (CommonSwarming.VerificationBitmap.of_string ver_str);
+         (VB.of_string ver_str);
      (*
      CommonSwarming.set_present s [(Int64.zero, file_size file)];
      (* If we don't verify now, it will never happen! *)
@@ -135,8 +138,10 @@
      *)
                 if !verbose_share then
                   lprintf_nl "verified map of %s = %s"
-             (codedname) (CommonSwarming.chunks_verified_bitmap s))
-      | None -> if !verbose_share then lprintf_nl "no swarmer for %s" 
codedname;
+            (codedname) (VB.to_string (CommonSwarming.chunks_verified_bitmap 
s))
+    | None -> 
+       if !verbose_share then 
+         lprintf_nl "no swarmer for %s" codedname;
     (try
         file.file_format <- CommonMultimedia.get_info
           (file_disk_name file)

Index: src/networks/fileTP/fileTPInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/fileTP/fileTPInteractive.ml,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- src/networks/fileTP/fileTPInteractive.ml    30 May 2006 10:54:14 -0000      
1.39
+++ src/networks/fileTP/fileTPInteractive.ml    11 Jun 2006 17:37:39 -0000      
1.40
@@ -47,6 +47,8 @@
 let _s x = _s "FileTPInteractive" x
 let _b x = _b "FileTPInteractive" x
 
+module VB = VerificationBitmap
+
 let _ =
   network.op_network_connected <- (fun _ -> true);
   network.op_network_connected_servers <- (fun _ -> [])
@@ -92,8 +94,9 @@
         P.file_all_sources = (List.length file.file_clients);
         P.file_active_sources = (List.length file.file_clients);
         P.file_chunks = (match file.file_swarmer with
-          None -> "" | Some swarmer ->
-            CommonSwarming.chunks_verified_bitmap swarmer);
+        | None -> None 
+       | Some swarmer ->
+            Some (CommonSwarming.chunks_verified_bitmap swarmer));
         P.file_availability =
         [network.network_num,(match file.file_swarmer with
           None -> "" | Some swarmer ->

Index: src/networks/gnutella/gnutellaInteractive.ml
===================================================================
RCS file: 
/sources/mldonkey/mldonkey/src/networks/gnutella/gnutellaInteractive.ml,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- src/networks/gnutella/gnutellaInteractive.ml        1 Jun 2006 01:40:28 
-0000       1.57
+++ src/networks/gnutella/gnutellaInteractive.ml        11 Jun 2006 17:37:39 
-0000      1.58
@@ -47,6 +47,8 @@
 open GnutellaComplexOptions
 open GnutellaProtocol
 
+module VB = VerificationBitmap
+
 (* Don't share files greater than 10 MB on Gnutella and limit to 200 files. 
  Why ? Because we don't store URNs currently, and we don't want mldonkey
  to compute hashes for hours at startup *)
@@ -297,8 +299,9 @@
         P.file_names = [file.file_name, P.noips()];
         
          P.file_chunks = (match file.file_swarmer with
-             None -> "" | Some swarmer ->
-               CommonSwarming.chunks_verified_bitmap swarmer);
+         | None -> None 
+        | Some swarmer -> 
+            Some (CommonSwarming.chunks_verified_bitmap swarmer));
         P.file_availability =   [network.network_num,
            (match file.file_swarmer with
            None -> "" | Some swarmer ->




reply via email to

[Prev in Thread] Current Thread [Next in Thread]