Baker: Fix nonces file cleanup

If it fails to fetch the metadata of a block it has a nonce for,
it drops the nonce.
This commit is contained in:
Pierre Boutillier 2018-11-15 13:22:08 +01:00 committed by Benjamin Canou
parent 8b839c9ad9
commit ede71b9e83

View File

@ -950,8 +950,10 @@ 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 } } } ->
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