diff --git a/src/proto_alpha/lib_protocol/src/storage.ml b/src/proto_alpha/lib_protocol/src/storage.ml index fa5ad22f2..dd859e0af 100644 --- a/src/proto_alpha/lib_protocol/src/storage.ml +++ b/src/proto_alpha/lib_protocol/src/storage.ml @@ -159,11 +159,6 @@ module Contract = struct (struct let name = ["counter"] end) (Z) - module Proposals = - Indexed_context.Make_map - (struct let name = ["proposals"] end) - (Int) - (* Consume gas for serilization and deserialization of expr in this module *) module Make_carbonated_map_expr (N : Storage_sigs.NAME) = struct @@ -531,6 +526,13 @@ module Vote = struct (Make_subcontext(Raw_context)(struct let name = ["proposals"] end)) (Pair(Make_index(Protocol_hash))(Make_index(Signature.Public_key_hash))) + module Proposals_count = + Make_indexed_data_storage + (Make_subcontext(Raw_context) + (struct let name = ["proposals_count"] end)) + (Make_index(Signature.Public_key_hash)) + (Int) + module Ballots = Make_indexed_data_storage (Make_subcontext(Raw_context)(struct let name = ["ballots"] end)) diff --git a/src/proto_alpha/lib_protocol/src/storage.mli b/src/proto_alpha/lib_protocol/src/storage.mli index 4ed13fe6b..809d5cf17 100644 --- a/src/proto_alpha/lib_protocol/src/storage.mli +++ b/src/proto_alpha/lib_protocol/src/storage.mli @@ -179,11 +179,6 @@ module Contract : sig and type value = Z.t and type t := Raw_context.t - module Proposals : Indexed_data_storage - with type key = Contract_repr.t - and type value = int - and type t := Raw_context.t - module Code : Non_iterable_indexed_carbonated_data_storage with type key = Contract_repr.t and type value = Script_repr.lazy_expr @@ -260,6 +255,11 @@ module Vote : sig with type elt = Protocol_hash.t * Signature.Public_key_hash.t and type t := Raw_context.t + module Proposals_count : Indexed_data_storage + with type key = Signature.Public_key_hash.t + and type value = int + and type t := Raw_context.t + module Ballots : Indexed_data_storage with type key = Signature.Public_key_hash.t and type value = Vote_repr.ballot diff --git a/src/proto_alpha/lib_protocol/src/vote_storage.ml b/src/proto_alpha/lib_protocol/src/vote_storage.ml index 23799dcc2..e2ec27815 100644 --- a/src/proto_alpha/lib_protocol/src/vote_storage.ml +++ b/src/proto_alpha/lib_protocol/src/vote_storage.ml @@ -24,15 +24,13 @@ (*****************************************************************************) let recorded_proposal_count_for_delegate ctxt proposer = - let delegate = Contract_repr.implicit_contract proposer in - Storage.Contract.Proposals.get_option ctxt delegate >>=? function + Storage.Vote.Proposals_count.get_option ctxt proposer >>=? function | None -> return 0 | Some count -> return count let record_proposal ctxt proposal proposer = recorded_proposal_count_for_delegate ctxt proposer >>=? fun count -> - let delegate = Contract_repr.implicit_contract proposer in - Storage.Contract.Proposals.init_set ctxt delegate (count + 1) >>= fun ctxt -> + Storage.Vote.Proposals_count.init_set ctxt proposer (count + 1) >>= fun ctxt -> Storage.Vote.Proposals.add ctxt (proposal, proposer) >>= fun ctxt -> return ctxt @@ -52,10 +50,7 @@ let get_proposals ctxt = end) let clear_proposals ctxt = - Storage.Delegates.fold ctxt ~init:ctxt ~f:begin fun proposer ctxt -> - let delegate = Contract_repr.implicit_contract proposer in - Storage.Contract.Proposals.remove ctxt delegate - end >>= fun ctxt -> + Storage.Vote.Proposals_count.clear ctxt >>= fun ctxt -> Storage.Vote.Proposals.clear ctxt type ballots = {