From fa3a9f2a4d5db1723112cac9492eca662e0d8478 Mon Sep 17 00:00:00 2001 From: thibauth Date: Tue, 6 Sep 2011 16:07:17 +0000 Subject: Chord git-svn-id: https://scm.gforge.inria.fr/svn/pacemaker@80 30fcff6e-8de6-41c7-acce-77ff6d1dd07b --- sources/thibaut/chord.ml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sources/thibaut/chord.ml 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 + -- cgit v1.2.3-70-g09d2