From ede71b9e83ca6d77f8bd769f5a13db2c71b5d914 Mon Sep 17 00:00:00 2001 From: Pierre Boutillier Date: Thu, 15 Nov 2018 13:22:08 +0100 Subject: [PATCH] Baker: Fix nonces file cleanup If it fails to fetch the metadata of a block it has a nonce for, it drops the nonce. --- .../lib_delegate/client_baking_forge.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index d1d1c2590..ed24fa705 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -950,12 +950,14 @@ let filter_outdated_nonces Block_hash.Map.fold begin fun hash nonce acc -> acc >>=? fun acc -> - Alpha_block_services.metadata cctxt ~chain ~block:(`Hash (hash, 0)) () >>=? - fun { protocol_data = { level = { Level.cycle } } } -> - if is_older_than_5_cycles cycle then - return acc - else - return (Block_hash.Map.add hash nonce acc) + Alpha_block_services.metadata cctxt ~chain ~block:(`Hash (hash, 0)) () >>= + function + | Result.Error _ -> return (Block_hash.Map.add hash nonce acc) + | Result.Ok { protocol_data = { level = { Level.cycle } } } -> + if is_older_than_5_cycles cycle then + return acc + else + return (Block_hash.Map.add hash nonce acc) end nonces (return Block_hash.Map.empty) >>=? fun new_nonces ->