diff --git a/src/node/net/p2p.ml b/src/node/net/p2p.ml index f19af5cfc..9bf11f423 100644 --- a/src/node/net/p2p.ml +++ b/src/node/net/p2p.ml @@ -434,8 +434,8 @@ let addr_encoding = let public_key_encoding = let open Data_encoding in conv - (fun public_key -> MBytes.to_string (Crypto_box.of_public_key public_key)) - (fun str -> Crypto_box.to_public_key (MBytes.of_string str)) + (MBytes.to_string << Crypto_box.of_public_key) + (Crypto_box.to_public_key << MBytes.of_string) string let peers_file_encoding = diff --git a/src/utils/utils.ml b/src/utils/utils.ml index ef2fe1f48..97969003d 100644 --- a/src/utils/utils.ml +++ b/src/utils/utils.ml @@ -121,3 +121,5 @@ let rec remove_elem_from_list nb = function | [] -> [] | l when nb <= 0 -> l | _ :: tl -> remove_elem_from_list (nb - 1) tl + +let (<<) g f = fun a -> g (f a) diff --git a/src/utils/utils.mli b/src/utils/utils.mli index a027b783f..f2abbdf92 100644 --- a/src/utils/utils.mli +++ b/src/utils/utils.mli @@ -38,3 +38,5 @@ val remove_elem_from_list: int -> 'a list -> 'a list val filter_map: ('a -> 'b option) -> 'a list -> 'b list +(** Compose functions from right to left. *) +val (<<) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c