Shell: minor renaming
Let's be consistent with Lwt (and ourselves).
This commit is contained in:
parent
4bbc97aeb6
commit
90780f3374
@ -271,7 +271,7 @@ end = struct
|
|||||||
| Error _ -> failwith "Json.write_file"
|
| Error _ -> failwith "Json.write_file"
|
||||||
| Ok () -> return ())
|
| Ok () -> return ())
|
||||||
(fun exn ->
|
(fun exn ->
|
||||||
Error_monad.failwith
|
failwith
|
||||||
"could not write the block file: %s."
|
"could not write the block file: %s."
|
||||||
(Printexc.to_string exn))
|
(Printexc.to_string exn))
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ let get_unrevealed_nonces cctxt ?(force = false) block =
|
|||||||
| Some cycle ->
|
| Some cycle ->
|
||||||
Client_mining_blocks.blocks_from_cycle
|
Client_mining_blocks.blocks_from_cycle
|
||||||
cctxt.rpc_config block cycle >>=? fun blocks ->
|
cctxt.rpc_config block cycle >>=? fun blocks ->
|
||||||
map_filter_s (fun hash ->
|
filter_map_s (fun hash ->
|
||||||
Client_proto_nonces.find cctxt hash >>= function
|
Client_proto_nonces.find cctxt hash >>= function
|
||||||
| None -> return None
|
| None -> return None
|
||||||
| Some nonce ->
|
| Some nonce ->
|
||||||
@ -466,7 +466,7 @@ let mine cctxt state =
|
|||||||
let slots = pop_mining_slots state in
|
let slots = pop_mining_slots state in
|
||||||
let seed_nonce = generate_seed_nonce () in
|
let seed_nonce = generate_seed_nonce () in
|
||||||
let seed_nonce_hash = Nonce.hash seed_nonce in
|
let seed_nonce_hash = Nonce.hash seed_nonce in
|
||||||
Error_monad.map_filter_s
|
filter_map_s
|
||||||
(fun (timestamp, (bi, priority, delegate)) ->
|
(fun (timestamp, (bi, priority, delegate)) ->
|
||||||
let block = `Hash bi.Client_mining_blocks.hash in
|
let block = `Hash bi.Client_mining_blocks.hash in
|
||||||
let timestamp =
|
let timestamp =
|
||||||
|
@ -75,7 +75,7 @@ let reveal_block_nonces cctxt ?force block_hashes =
|
|||||||
Block_hash.pp_short hash >>= fun () ->
|
Block_hash.pp_short hash >>= fun () ->
|
||||||
Lwt.return_none))
|
Lwt.return_none))
|
||||||
block_hashes >>= fun block_infos ->
|
block_hashes >>= fun block_infos ->
|
||||||
map_filter_s (fun (bi : Client_mining_blocks.block_info) ->
|
filter_map_s (fun (bi : Client_mining_blocks.block_info) ->
|
||||||
Client_proto_nonces.find cctxt bi.hash >>= function
|
Client_proto_nonces.find cctxt bi.hash >>= function
|
||||||
| None ->
|
| None ->
|
||||||
cctxt.warning "Cannot find nonces for block %a (ignoring)@."
|
cctxt.warning "Cannot find nonces for block %a (ignoring)@."
|
||||||
|
@ -99,8 +99,8 @@ val map2_s :
|
|||||||
('a -> 'b -> 'c tzresult Lwt.t) -> 'a list -> 'b list ->
|
('a -> 'b -> 'c tzresult Lwt.t) -> 'a list -> 'b list ->
|
||||||
'c list tzresult Lwt.t
|
'c list tzresult Lwt.t
|
||||||
|
|
||||||
(** A {!List.map_filter} in the monad *)
|
(** A {!List.filter_map} in the monad *)
|
||||||
val map_filter_s : ('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t
|
val filter_map_s : ('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t
|
||||||
|
|
||||||
(** A {!List.fold_left} in the monad *)
|
(** A {!List.fold_left} in the monad *)
|
||||||
val fold_left_s : ('a -> 'b -> 'a tzresult Lwt.t) -> 'a -> 'b list -> 'a tzresult Lwt.t
|
val fold_left_s : ('a -> 'b -> 'a tzresult Lwt.t) -> 'a -> 'b list -> 'a tzresult Lwt.t
|
||||||
|
@ -269,22 +269,22 @@ module Make() = struct
|
|||||||
map2 f t1 t2 >>? fun rt ->
|
map2 f t1 t2 >>? fun rt ->
|
||||||
Ok (rh :: rt)
|
Ok (rh :: rt)
|
||||||
|
|
||||||
let rec map_filter_s f l =
|
let rec filter_map_s f l =
|
||||||
match l with
|
match l with
|
||||||
| [] -> return []
|
| [] -> return []
|
||||||
| h :: t ->
|
| h :: t ->
|
||||||
f h >>=? function
|
f h >>=? function
|
||||||
| None -> map_filter_s f t
|
| None -> filter_map_s f t
|
||||||
| Some rh ->
|
| Some rh ->
|
||||||
map_filter_s f t >>=? fun rt ->
|
filter_map_s f t >>=? fun rt ->
|
||||||
return (rh :: rt)
|
return (rh :: rt)
|
||||||
|
|
||||||
let rec map_filter_p f l =
|
let rec filter_map_p f l =
|
||||||
match l with
|
match l with
|
||||||
| [] -> return []
|
| [] -> return []
|
||||||
| h :: t ->
|
| h :: t ->
|
||||||
let th = f h
|
let th = f h
|
||||||
and tt = map_filter_s f t in
|
and tt = filter_map_s f t in
|
||||||
th >>=? function
|
th >>=? function
|
||||||
| None -> tt
|
| None -> tt
|
||||||
| Some rh ->
|
| Some rh ->
|
||||||
|
@ -134,10 +134,10 @@ module type S = sig
|
|||||||
('a -> 'b -> 'c tzresult Lwt.t) -> 'a list -> 'b list ->
|
('a -> 'b -> 'c tzresult Lwt.t) -> 'a list -> 'b list ->
|
||||||
'c list tzresult Lwt.t
|
'c list tzresult Lwt.t
|
||||||
|
|
||||||
(** A {!List.map_filter} in the monad *)
|
(** A {!List.filter_map} in the monad *)
|
||||||
val map_filter_s :
|
val filter_map_s :
|
||||||
('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t
|
('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t
|
||||||
val map_filter_p :
|
val filter_map_p :
|
||||||
('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t
|
('a -> 'b option tzresult Lwt.t) -> 'a list -> 'b list tzresult Lwt.t
|
||||||
|
|
||||||
(** A {!List.fold_left} in the monad *)
|
(** A {!List.fold_left} in the monad *)
|
||||||
|
Loading…
Reference in New Issue
Block a user