Shell: avoid operation leaks

This commit is contained in:
Grégoire Henry 2017-03-06 15:55:02 +01:00
parent 3b483811f5
commit 39403e243e
2 changed files with 5 additions and 2 deletions

View File

@ -134,8 +134,8 @@ end = struct
let commit s k = let commit s k =
match Memory_table.find s.memory k with match Memory_table.find s.memory k with
| exception Not_found -> Lwt.return_unit (* TODO error ?? *) | exception Not_found -> Lwt.return_unit
| Pending _ -> Lwt.return_unit (* TODO error ?? *) | Pending _ -> assert false
| Found v -> | Found v ->
Disk_table.store s.disk v >>= fun _ -> Disk_table.store s.disk v >>= fun _ ->
Memory_table.remove s.memory k ; Memory_table.remove s.memory k ;

View File

@ -294,6 +294,9 @@ module Context_db = struct
State.Valid_block.store net_state hash data >>=? function State.Valid_block.store net_state hash data >>=? function
| None -> | None ->
State.Valid_block.read net_state hash >>=? fun block -> State.Valid_block.read net_state hash >>=? fun block ->
Lwt_list.iter_p (fun hash ->
Distributed_db.Operation.commit net_db hash)
block.operations >>= fun () ->
return (Ok block, false) return (Ok block, false)
| Some block -> | Some block ->
return (Ok block, true) return (Ok block, true)