summaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/thibaut/chord.ml27
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/thibaut/chord.ml b/sources/thibaut/chord.ml
new file mode 100644
index 0000000..cb3ad2a
--- /dev/null
+++ b/sources/thibaut/chord.ml
@@ -0,0 +1,27 @@
+open Globals
+open SlotArray
+
+
+let do_peer root peer =
+
+ let aux = function
+ | Ask p -> ask_peer peer p
+ | _ -> failwith "Big problem"
+ in
+
+ SlotArray.filter_peers is_active peer.slots;
+ SlotArray.iter_asks aux peer.slots;
+ let free_slots = SlotArray.capacity peer.slots - SlotArray.length peer.slots
+ - SlotArray.asks peer.slots in
+ if free_slots > 2 then
+ let (a,b) = ask_root root peer in
+ if a then begin
+ SlotArray.accept (Peer root) peer.slots;
+ SlotArray.append_asks b peer.slots
+ end
+ else
+ SlotArray.append_asks b peer.slots
+
+let do_server root =
+ SlotArray.filter_peers is_active root.slots
+