Skip to content

Commit 161ff68

Browse files
committed
use strings for client id
1 parent fdc121b commit 161ff68

22 files changed

+111
-78
lines changed

extraction/aggregation-dynamic/coq/ExtractTreeAggregation.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Require Import mathcomp.algebra.zmodp.
1717

1818
Require Import ExtrOcamlBasic.
1919
Require Import ExtrOcamlNatInt.
20+
Require Import ExtrOcamlString.
2021

2122
Require Import ExtrOcamlBasicExt.
2223
Require Import ExtrOcamlNatIntExt.

extraction/aggregation-dynamic/ocaml/Serialization.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ open Printf
33
open Scanf
44
open TreeAggregation
55
open TreeAggregationNames
6+
open Util
67

78
let serializeName : Names.name -> string = string_of_int
89

@@ -16,24 +17,24 @@ let deserializeMsg : string -> coq_Msg = fun s ->
1617
let serializeMsg : coq_Msg -> string = fun msg ->
1718
Marshal.to_string msg []
1819

19-
let deserializeInput (s : string) (client_id : int) : coq_Input option =
20+
let deserializeInput (s : string) (c : string) : coq_Input option =
2021
match s with
2122
| "SendAggregate" -> Some SendAggregate
2223
| "Broadcast" -> Some Broadcast
23-
| "AggregateRequest" -> Some (AggregateRequest client_id)
24-
| "LevelRequest" -> Some (LevelRequest client_id)
24+
| "AggregateRequest" -> Some (AggregateRequest (char_list_of_string c))
25+
| "LevelRequest" -> Some (LevelRequest (char_list_of_string c))
2526
| _ ->
26-
try sscanf s "Local %d" (fun x -> Some (Local (Obj.magic x)))
27+
try Scanf.sscanf s "Local %d" (fun x -> Some (Local (Obj.magic x)))
2728
with _ -> None
2829

2930
let serializeLevelOption olv : string =
3031
match olv with
3132
| Some lv -> string_of_int lv
3233
| _ -> ""
3334

34-
let serializeOutput : coq_Output -> int * string = function
35-
| AggregateResponse (client_id, x) -> (client_id, sprintf "AggregateResponse %d" (Obj.magic x))
36-
| LevelResponse (client_id, olv) -> (client_id, sprintf "LevelResponse %s" (serializeLevelOption olv))
35+
let serializeOutput : coq_Output -> string * string = function
36+
| AggregateResponse (c, x) -> (string_of_char_list c, sprintf "AggregateResponse %d" (Obj.magic x))
37+
| LevelResponse (c, olv) -> (string_of_char_list c, sprintf "LevelResponse %s" (serializeLevelOption olv))
3738

3839
let debugSerializeInput : coq_Input -> string = function
3940
| SendAggregate -> "SendAggregate"

extraction/aggregation-dynamic/ocaml/TreeAggregationArrangement.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module TreeAggregationArrangement = struct
88
type output = coq_Output
99
type msg = coq_Msg
1010
type res = (output list * state) * ((name * msg) list)
11+
type client_id = string
1112

1213
let systemName : string = "Dynamic Tree Aggregation Protocol"
1314

@@ -28,13 +29,13 @@ module TreeAggregationArrangement = struct
2829

2930
let setTimeout : name -> state -> float = fun _ _ -> 1.0
3031

31-
let deserializeMsg : string -> msg = Serialization.deserializeMsg
32+
let deserializeMsg = Serialization.deserializeMsg
3233

33-
let serializeMsg : msg -> string = Serialization.serializeMsg
34+
let serializeMsg = Serialization.serializeMsg
3435

3536
let deserializeInput = Serialization.deserializeInput
3637

37-
let serializeOutput : output -> int * string = Serialization.serializeOutput
38+
let serializeOutput = Serialization.serializeOutput
3839

3940
let failMsg = Some Fail
4041

@@ -55,5 +56,6 @@ module TreeAggregationArrangement = struct
5556
print_newline ()
5657

5758
let debugTimeout : state -> unit = fun _ -> ()
58-
end
5959

60+
let createClientId () = Uuidm.to_string (Uuidm.create `V4)
61+
end

extraction/aggregation/coq/ExtractTreeAggregation.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Require Import mathcomp.algebra.zmodp.
1818

1919
Require Import ExtrOcamlBasic.
2020
Require Import ExtrOcamlNatInt.
21+
Require Import ExtrOcamlString.
2122

2223
Require Import ExtrOcamlBasicExt.
2324
Require Import ExtrOcamlNatIntExt.

extraction/aggregation/ocaml/Serialization.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ open Printf
33
open Scanf
44
open TreeAggregation
55
open TreeAggregationNames
6+
open Util
67

78
let serializeName : Names.name -> string = string_of_int
89

@@ -16,12 +17,12 @@ let deserializeMsg : string -> coq_Msg = fun s ->
1617
let serializeMsg : coq_Msg -> string = fun msg ->
1718
Marshal.to_string msg []
1819

19-
let deserializeInput (s : string) (client_id : int) : coq_Input option =
20+
let deserializeInput (s : string) (c : string) : coq_Input option =
2021
match s with
2122
| "SendAggregate" -> Some SendAggregate
2223
| "Broadcast" -> Some Broadcast
23-
| "AggregateRequest" -> Some (AggregateRequest client_id)
24-
| "LevelRequest" -> Some (LevelRequest client_id)
24+
| "AggregateRequest" -> Some (AggregateRequest (char_list_of_string c))
25+
| "LevelRequest" -> Some (LevelRequest (char_list_of_string c))
2526
| _ ->
2627
try Scanf.sscanf s "Local %d" (fun x -> Some (Local (Obj.magic x)))
2728
with _ -> None
@@ -31,9 +32,9 @@ let serializeLevelOption olv : string =
3132
| Some lv -> string_of_int lv
3233
| _ -> "-"
3334

34-
let serializeOutput : coq_Output -> int * string = function
35-
| AggregateResponse (client_id, x) -> (client_id, sprintf "AggregateResponse %d" (Obj.magic x))
36-
| LevelResponse (client_id, olv) -> (client_id, sprintf "LevelResponse %s" (serializeLevelOption olv))
35+
let serializeOutput : coq_Output -> string * string = function
36+
| AggregateResponse (c, x) -> (string_of_char_list c, sprintf "AggregateResponse %d" (Obj.magic x))
37+
| LevelResponse (c, olv) -> (string_of_char_list c, sprintf "LevelResponse %s" (serializeLevelOption olv))
3738

3839
let debugSerializeInput : coq_Input -> string = function
3940
| SendAggregate -> "SendAggregate"

extraction/aggregation/ocaml/TreeAggregationArrangement.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module TreeAggregationArrangement = struct
88
type output = coq_Output
99
type msg = coq_Msg
1010
type res = (output list * state) * ((name * msg) list)
11+
type client_id = string
1112

1213
let systemName : string = "Static Tree Aggregation Protocol"
1314

@@ -32,9 +33,9 @@ module TreeAggregationArrangement = struct
3233

3334
let serializeMsg : msg -> string = Serialization.serializeMsg
3435

35-
let deserializeInput : string -> int -> input option = Serialization.deserializeInput
36+
let deserializeInput : string -> client_id -> input option = Serialization.deserializeInput
3637

37-
let serializeOutput : output -> int * string = Serialization.serializeOutput
38+
let serializeOutput : output -> client_id * string = Serialization.serializeOutput
3839

3940
let failMsg : msg option = Some Fail
4041

@@ -55,4 +56,6 @@ module TreeAggregationArrangement = struct
5556
print_newline ()
5657

5758
let debugTimeout : state -> unit = fun _ -> ()
59+
60+
let createClientId () = Uuidm.to_string (Uuidm.create `V4)
5861
end

extraction/tree-dynamic/coq/ExtractTree.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Require Import StructTact.Fin.
88

99
Require Import ExtrOcamlBasic.
1010
Require Import ExtrOcamlNatInt.
11+
Require Import ExtrOcamlString.
1112

1213
Require Import ExtrOcamlBasicExt.
1314
Require Import ExtrOcamlNatIntExt.

extraction/tree-dynamic/ocaml/Serialization.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ open Printf
33
open Scanf
44
open Tree
55
open TreeNames
6+
open Util
67

78
let serializeName : Names.name -> string = string_of_int
89

@@ -16,19 +17,19 @@ let deserializeMsg : string -> coq_Msg = fun s ->
1617
let serializeMsg : coq_Msg -> string = fun msg ->
1718
Marshal.to_string msg []
1819

19-
let deserializeInput (s : string) (client_id : int) : coq_Input option =
20+
let deserializeInput (s : string) (c : string) : coq_Input option =
2021
match s with
2122
| "Broadcast" -> Some Broadcast
22-
| "LevelRequest" -> Some (LevelRequest client_id)
23+
| "LevelRequest" -> Some (LevelRequest (char_list_of_string c))
2324
| _ -> None
2425

2526
let serializeLevelOption olv : string =
2627
match olv with
2728
| Some lv -> string_of_int lv
2829
| _ -> "-"
2930

30-
let serializeOutput : coq_Output -> int * string = function
31-
| LevelResponse (client_id, olv) -> (client_id, sprintf "LevelResponse %s" (serializeLevelOption olv))
31+
let serializeOutput : coq_Output -> string * string = function
32+
| LevelResponse (c, olv) -> (string_of_char_list c, sprintf "LevelResponse %s" (serializeLevelOption olv))
3233

3334
let debugSerializeInput : coq_Input -> string = function
3435
| Broadcast -> "Broadcast"

extraction/tree-dynamic/ocaml/TreeArrangement.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module TreeArrangement = struct
88
type output = coq_Output
99
type msg = coq_Msg
1010
type res = (output list * state) * ((name * msg) list)
11+
type client_id = string
1112

1213
let systemName : string = "Dynamic Tree Building Protocol"
1314

@@ -55,4 +56,6 @@ module TreeArrangement = struct
5556
print_newline ()
5657

5758
let debugTimeout : state -> unit = fun _ -> ()
59+
60+
let createClientId () = Uuidm.to_string (Uuidm.create `V4)
5861
end

extraction/tree/coq/ExtractTree.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Require Import StructTact.Fin.
88

99
Require Import ExtrOcamlBasic.
1010
Require Import ExtrOcamlNatInt.
11+
Require Import ExtrOcamlString.
1112

1213
Require Import ExtrOcamlBasicExt.
1314
Require Import ExtrOcamlNatIntExt.

0 commit comments

Comments
 (0)