Client/Endorser: remove older endorsement from wallet

This commit is contained in:
Mathias 2018-05-22 19:40:47 +02:00 committed by Grégoire Henry
parent c4549650b5
commit d82c811bdd

View File

@ -60,12 +60,16 @@ end = struct
load wallet >>=? fun l -> load wallet >>=? fun l ->
let delegate_key = Signature.Public_key_hash.to_short_b58check delegate let delegate_key = Signature.Public_key_hash.to_short_b58check delegate
in in
match List.assoc_opt delegate_key l with let rec remove_old acc = function
| None -> | [] -> List.rev acc
save wallet ((delegate_key, new_lvl)::l) | ((_,lvl) as hd)::tl ->
| Some _ -> if Raw_level.diff new_lvl lvl > 50l (*?*) then
save wallet ((delegate_key, new_lvl):: remove_old (hd::acc) tl
List.remove_assoc delegate_key l) else
List.rev acc
in
save wallet ((delegate_key, new_lvl)::
List.remove_assoc delegate_key (remove_old [] l))
end) end)
end end
end end