Verified Commit 7206ccd5 authored by Arthur B.'s avatar Arthur B. 🐻 Committed by Grégoire Henry

Indentation fixes

parent a10932b5
(rule
(targets v1.ml)
(deps
;; Part of OCaml stdlib
v1/pervasives.mli
v1/list.mli
......
......@@ -22,7 +22,7 @@
reasonably efficient: insertion and membership take time
logarithmic in the size of the set, for instance.
The {!Make} functor constructs implementations for any type, given a
The {!Make} functor constructs implementations for any type, given a
[compare] function.
For instance:
{[
......
......@@ -622,7 +622,7 @@ module Make
type config = {
root : string option ;
mapsize : int64 ;
readonly : bool ;
readonly : bool ;
(* TODO *)
(* ?write_buffer_size:int -> *)
(* ?max_open_files:int -> *)
......@@ -641,7 +641,7 @@ module Make
let { root ; mapsize ; readonly } = config conf in
let root = match root with None -> "irmin.ldb" | Some root -> root in
if not (Sys.file_exists root) then Unix.mkdir root 0o755 ;
let flags = Lmdb.NoTLS :: if readonly then [ Lmdb.RdOnly ] else [] in
let flags = Lmdb.NoTLS :: if readonly then [ Lmdb.RdOnly ] else [] in
let file_flags = if readonly then 0o444 else 0o644 in
match Lmdb.opendir ~mapsize ~flags root file_flags with
| Error err -> Lwt.fail_with (Lmdb.string_of_error err)
......
......@@ -12,7 +12,7 @@ module Version = struct
| Tezos -> Format.pp_print_string ppf "Tezos"
| TezBake -> Format.pp_print_string ppf "TezBake"
let class_of_int = function
let class_of_int = function
| 0 -> Tezos
| 1 -> TezBake
| _ -> invalid_arg "class_of_int"
......
......@@ -117,7 +117,7 @@ module Header = struct
let read cs =
let cslen = Cstruct.len cs in
begin if cslen < 5 then
fail_header_too_short cslen
fail_header_too_short cslen
else R.ok ()
end >>= fun () ->
let channel_id = Cstruct.BE.get_uint16 cs 0 in
......@@ -129,8 +129,8 @@ module Header = struct
else R.ok ()
end >>= fun () ->
begin match cmd_of_int cmd with
| Some cmd -> R.ok cmd
| None -> fail_invalid_cmd cmd
| Some cmd -> R.ok cmd
| None -> fail_invalid_cmd cmd
end >>= fun cmd ->
R.ok ({ cmd ; seq }, Cstruct.shift cs 5)
......
......@@ -253,20 +253,20 @@ let opendir ?maxreaders ?maxdbs ?mapsize ?(flags=[]) path mode =
match create () with
| Error v -> Error (error_of_int v)
| Ok t ->
begin match maxreaders with
| None -> Ok ()
| Some readers -> set_maxreaders t readers
end >>= fun () ->
begin match maxdbs with
| None -> Ok ()
| Some dbs -> set_maxdbs t dbs
end >>= fun () ->
begin match mapsize with
| None -> Ok ()
| Some size -> set_mapsize t size
end >>= fun () ->
let ret = opendir t path (int_of_flags_env flags) mode in
return ret t ~on_error:(fun () -> closedir t)
begin match maxreaders with
| None -> Ok ()
| Some readers -> set_maxreaders t readers
end >>= fun () ->
begin match maxdbs with
| None -> Ok ()
| Some dbs -> set_maxdbs t dbs
end >>= fun () ->
begin match mapsize with
| None -> Ok ()
| Some size -> set_mapsize t size
end >>= fun () ->
let ret = opendir t path (int_of_flags_env flags) mode in
return ret t ~on_error:(fun () -> closedir t)
external copy :
t -> string -> int -> int = "stub_mdb_env_copy2" [@@noalloc]
......@@ -425,28 +425,28 @@ let with_ro_db ?sync ?metasync ?parent ?flags ?name t ~f =
opendb ?flags ?name txn >>= fun db ->
match f txn db with
| exception exn ->
abort_txn txn ;
raise exn
abort_txn txn ;
raise exn
| Ok res ->
commit_txn txn >>= fun () ->
Ok res
commit_txn txn >>= fun () ->
Ok res
| Error err ->
abort_txn txn ;
Error err
abort_txn txn ;
Error err
let with_rw_db ?sync ?metasync ?parent ?flags ?name t ~f =
create_rw_txn ?sync ?metasync ?parent t >>= fun txn ->
opendb ?flags ?name txn >>= fun db ->
match f txn db with
| exception exn ->
abort_txn txn ;
raise exn
abort_txn txn ;
raise exn
| Ok res ->
commit_txn txn >>= fun () ->
Ok res
commit_txn txn >>= fun () ->
Ok res
| Error err ->
abort_txn txn ;
Error err
abort_txn txn ;
Error err
type buffer = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
......@@ -504,10 +504,10 @@ external opencursor :
let opencursor :
type a. a txn -> db -> (a cursor, error) result = fun txn dbi ->
match txn with
| Txn_ro rawtxn ->
| Txn_ro rawtxn ->
R.reword_error error_of_int (opencursor rawtxn dbi) |>
R.map cursor_ro
| Txn_rw rawtxn ->
| Txn_rw rawtxn ->
R.reword_error error_of_int (opencursor rawtxn dbi) |>
R.map cursor_rw
......@@ -586,11 +586,11 @@ let cursor_fold_left ~f ~init cursor =
| Error KeyNotFound -> Ok a
| Error err -> Error err
| Ok kv ->
f a kv >>= fun a ->
match cursor_next cursor with
| Error KeyNotFound -> Ok a
| Error err -> Error err
| Ok () -> inner a
f a kv >>= fun a ->
match cursor_next cursor with
| Error KeyNotFound -> Ok a
| Error err -> Error err
| Ok () -> inner a
in
inner init
......
......@@ -13,7 +13,7 @@ let cdiv x y =
exposed _internal_ utility library not for public consumption, hence
the API break that prompted this copy-pasted function. *)
if y < 1 then raise Division_by_zero else
if x > 0 then 1 + ((x - 1) / y) else 0 [@@inline]
if x > 0 then 1 + ((x - 1) / y) else 0 [@@inline]
module type S = sig
val pbkdf2 : password:Bigstring.t -> salt:Bigstring.t -> count:int -> dk_len:int32 -> Bigstring.t
......
......@@ -99,22 +99,22 @@ let equal : type a b. (a, b) key -> (a, b) key -> bool = fun k1 k2 ->
match k1, k2 with
| Sk (sk, _), Sk (sk2, _) -> Bigstring.equal sk sk2
| Pk (pk, c), Pk (pk2, _) ->
let len = compressed_size c in
let cpk = Bigstring.create len in
let cpk2 = Bigstring.create len in
compress pk cpk (to_curve c) ;
compress pk2 cpk2 (to_curve c) ;
Bigstring.equal cpk cpk2
let len = compressed_size c in
let cpk = Bigstring.create len in
let cpk2 = Bigstring.create len in
compress pk cpk (to_curve c) ;
compress pk2 cpk2 (to_curve c) ;
Bigstring.equal cpk cpk2
let neuterize : type a b. (a, b) key -> (a, public) key = function
| Pk (pk, curve) -> Pk (pk, curve)
| Sk (sk, curve) ->
let pk = Bigstring.create (pk_size curve) in
let pk_computed_ok = pk_of_sk sk pk (to_curve curve) in
let pk_is_valid = valid_pk pk (to_curve curve) in
if not pk_computed_ok && pk_is_valid then
invalid_arg "Uecc.neuterize" ;
Pk (pk, curve)
let pk = Bigstring.create (pk_size curve) in
let pk_computed_ok = pk_of_sk sk pk (to_curve curve) in
let pk_is_valid = valid_pk pk (to_curve curve) in
if not pk_computed_ok && pk_is_valid then
invalid_arg "Uecc.neuterize" ;
Pk (pk, curve)
let pk_of_bytes :
type a. a t -> Bigstring.t ->
......@@ -216,18 +216,18 @@ external verify :
let write_sign (Sk (_sk, _c)) _buf ~msg:_ =
failwith "Not implemented"
(* if Bigstring.length buf < pk_size c then 0
* else
* match sign sk msg buf (to_curve c) with
* | true -> pk_size c
* | false -> 0 *)
(* if Bigstring.length buf < pk_size c then 0
* else
* match sign sk msg buf (to_curve c) with
* | true -> pk_size c
* | false -> 0 *)
let sign (Sk (_sk, _c)) _msg =
failwith "Not implemented"
(* let signature = Bigstring.create (pk_size c) in
* match sign sk msg signature (to_curve c) with
* | true -> Some signature
* | false -> None *)
(* let signature = Bigstring.create (pk_size c) in
* match sign sk msg signature (to_curve c) with
* | true -> Some signature
* | false -> None *)
let verify (Pk (pk, c)) ~msg ~signature =
if Bigstring.length signature <> pk_size c then false
......
......@@ -25,18 +25,18 @@ let test_export_curve curve =
match keypair curve with
| None -> assert false
| Some (sk, pk) ->
let sk_bytes = to_bytes ~compress:false sk in
let pk_bytes = to_bytes ~compress:false pk in
checki __LOC__ (sk_size curve) (Bigstring.length sk_bytes) ;
checki __LOC__ (pk_size curve + 1) (Bigstring.length pk_bytes) ;
match sk_of_bytes curve sk_bytes,
pk_of_bytes curve pk_bytes with
| Some (sk', pk'), Some pk'' ->
assert (equal sk sk') ;
assert (equal pk pk') ;
assert (equal pk pk'') ;
assert (equal pk' pk') ;
| _ -> assert false
let sk_bytes = to_bytes ~compress:false sk in
let pk_bytes = to_bytes ~compress:false pk in
checki __LOC__ (sk_size curve) (Bigstring.length sk_bytes) ;
checki __LOC__ (pk_size curve + 1) (Bigstring.length pk_bytes) ;
match sk_of_bytes curve sk_bytes,
pk_of_bytes curve pk_bytes with
| Some (sk', pk'), Some pk'' ->
assert (equal sk sk') ;
assert (equal pk pk') ;
assert (equal pk pk'') ;
assert (equal pk' pk') ;
| _ -> assert false
let test_export_curve curve =
for _i = 0 to nb_iterations - 1 do
......@@ -55,18 +55,18 @@ let test_export_curve_compressed curve =
match keypair curve with
| None -> assert false
| Some (sk, pk) ->
let sk_bytes = to_bytes sk in
let pk_bytes = to_bytes pk in
checki __LOC__ (sk_size curve) (Bigstring.length sk_bytes) ;
checki __LOC__ (compressed_size curve) (Bigstring.length pk_bytes) ;
match sk_of_bytes curve sk_bytes,
pk_of_bytes curve pk_bytes with
| Some (sk', pk'), Some pk'' ->
assert (equal sk sk') ;
assert (equal pk pk') ;
assert (equal pk pk'') ;
assert (equal pk' pk') ;
| _ -> assert false
let sk_bytes = to_bytes sk in
let pk_bytes = to_bytes pk in
checki __LOC__ (sk_size curve) (Bigstring.length sk_bytes) ;
checki __LOC__ (compressed_size curve) (Bigstring.length pk_bytes) ;
match sk_of_bytes curve sk_bytes,
pk_of_bytes curve pk_bytes with
| Some (sk', pk'), Some pk'' ->
assert (equal sk sk') ;
assert (equal pk pk') ;
assert (equal pk pk'') ;
assert (equal pk' pk') ;
| _ -> assert false
let test_export_curve_compressed curve =
for _i = 0 to nb_iterations - 1 do
......@@ -85,10 +85,10 @@ let test_keypair_curve curve =
match keypair curve with
| None -> assert false
| Some (sk, pk) ->
assert (equal sk sk) ;
assert (equal pk pk) ;
let pk' = neuterize sk in
assert (equal pk pk')
assert (equal sk sk) ;
assert (equal pk pk) ;
let pk' = neuterize sk in
assert (equal pk pk')
let test_keypair_curve curve =
for _i = 0 to nb_iterations - 1 do
......@@ -106,11 +106,11 @@ let test_keypair () =
let test_dh_curve curve =
match keypair curve, keypair curve with
| Some (sk, pk), Some (sk', pk') ->
begin match dh sk pk', dh sk' pk with
| Some secret, Some secret' ->
assert (Bigstring.equal secret secret')
| _ -> assert false
end
begin match dh sk pk', dh sk' pk with
| Some secret, Some secret' ->
assert (Bigstring.equal secret secret')
| _ -> assert false
end
| _ -> assert false
let test_dh_curve curve =
......@@ -133,16 +133,16 @@ let test_sign_curve curve =
match keypair curve with
| None -> assert false
| Some (sk, pk) ->
let signature = Bigstring.create (pk_size curve) in
begin match write_sign sk signature ~msg with
| nb_written when nb_written = (pk_size curve) ->
assert (verify pk ~msg ~signature)
| _ -> assert false
end ;
match sign sk msg with
| None -> assert false
| Some signature ->
assert (verify pk ~msg ~signature)
let signature = Bigstring.create (pk_size curve) in
begin match write_sign sk signature ~msg with
| nb_written when nb_written = (pk_size curve) ->
assert (verify pk ~msg ~signature)
| _ -> assert false
end ;
match sign sk msg with
| None -> assert false
| Some signature ->
assert (verify pk ~msg ~signature)
let test_sign_curve curve =
for _i = 0 to nb_iterations - 1 do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment