-
Notifications
You must be signed in to change notification settings - Fork 0
/
intf.ml
62 lines (48 loc) · 1.47 KB
/
intf.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
module type Application = sig
type transition
type state
val initial : state
val apply : transition -> state -> state
val propose : unit -> transition
val verify : transition -> bool
end
module type DSA = sig
type public_key
type private_key
type 'a signature
val signature : secret:private_key -> 'a -> 'a signature
val verify : id:public_key -> 'a -> 'a signature -> bool
val generate_id : unit -> public_key * private_key
val string_of_id : public_key -> string
val int_of_id : public_key -> int
end
module type Hash = sig
type 'a t
val hash : 'a -> 'a t
val equal : 'a t -> 'a t -> bool
val to_string : 'a t -> string
end
module type Weight = sig
val weigh : 'a -> int
val max_weight : int
end
module type Broadcast = sig
type message
val send : message -> unit
end
module type Node = sig
type message
type state
val on_receive : message -> bool
(** Handle received message. Returns true iff message was fresh (Implies
message should be relayed and broadcast continued). *)
(* TODO: could also return something like Fresh | Old | Invalid. *)
val work : unit -> unit
(** Search ATVs with proof-of-work. Found solutions are handed to [on_atv]. *)
val on_atv : int -> unit
(** Make us of an ATV. [on_atv sol] uses [sol] as solution in a vote. Only
works when [sol] satisfies threshold rule for currently preferred block.
*)
val get_state : unit -> state
(** Extract committed application state. *)
end