Proto: Rename Public_key to Delegates_pubkey
This commit is contained in:
parent
de8967540f
commit
102ba49149
@ -174,7 +174,7 @@ let apply_sourced_operation
|
||||
(ctxt, origination_nonce, None) contents
|
||||
| Delegate_operations { source ; operations = contents } ->
|
||||
let delegate = Ed25519.Public_key.hash source in
|
||||
Public_key.reveal ctxt delegate source >>=? fun ctxt ->
|
||||
Delegates_pubkey.reveal ctxt delegate source >>=? fun ctxt ->
|
||||
Operation.check_signature source operation >>=? fun () ->
|
||||
(* TODO, see how to extract the public key hash after this operation to
|
||||
pass it to apply_delegate_operation_content *)
|
||||
|
@ -232,7 +232,7 @@ let check_proof_of_work_stamp ctxt block =
|
||||
fail Invalid_stamp
|
||||
|
||||
let check_signature ctxt block id =
|
||||
Public_key.get ctxt id >>=? fun key ->
|
||||
Delegates_pubkey.get ctxt id >>=? fun key ->
|
||||
let check_signature key { Block_header.proto ; shell ; signature } =
|
||||
let unsigned_header = Block_header.forge_unsigned shell proto in
|
||||
Ed25519.Signature.check key signature unsigned_header in
|
||||
|
@ -190,7 +190,7 @@ let create_base c contract ~balance ~manager ~delegate ?script ~spendable ~deleg
|
||||
| None -> return 0l
|
||||
| Some _ -> Storage.Contract.Global_counter.get c) >>=? fun counter ->
|
||||
Storage.Contract.Balance.init c contract balance >>=? fun c ->
|
||||
Storage.Contract.Manager.init c contract (Manager_repr.hash manager) >>=? fun c ->
|
||||
Storage.Contract.Manager.init c contract (Manager_repr.Hash manager) >>=? fun c ->
|
||||
begin
|
||||
match delegate with
|
||||
| None -> return c
|
||||
@ -310,7 +310,7 @@ let update_manager_key c contract = function
|
||||
| (Manager_repr.Hash v) ->
|
||||
let actual_hash = Ed25519.Public_key.hash public_key in
|
||||
if (Ed25519.Public_key_hash.equal actual_hash v) then
|
||||
let v = (Manager_repr.public_key public_key) in
|
||||
let v = (Manager_repr.Public_key public_key) in
|
||||
Storage.Contract.Manager.set c contract v >>=? fun c ->
|
||||
return (c,public_key) (* reveal and update key *)
|
||||
else fail (Inconsistent_hash (public_key,v,actual_hash))
|
||||
|
@ -15,30 +15,17 @@ type manager_key =
|
||||
|
||||
type t = manager_key
|
||||
|
||||
let hash hash = Hash hash
|
||||
let public_key hash = Public_key hash
|
||||
|
||||
open Data_encoding
|
||||
|
||||
let hash_encoding =
|
||||
(obj1
|
||||
(req "hash" Ed25519.Public_key_hash.encoding)
|
||||
)
|
||||
|
||||
let pubkey_encoding =
|
||||
(obj1
|
||||
(req "public_key" Ed25519.Public_key.encoding)
|
||||
)
|
||||
|
||||
let hash_case tag =
|
||||
case ~tag hash_encoding
|
||||
case ~tag Ed25519.Public_key_hash.encoding
|
||||
(function
|
||||
| Hash hash -> Some hash
|
||||
| _ -> None)
|
||||
(fun hash -> Hash hash)
|
||||
|
||||
let pubkey_case tag =
|
||||
case ~tag pubkey_encoding
|
||||
case ~tag Ed25519.Public_key.encoding
|
||||
(function
|
||||
| Public_key hash -> Some hash
|
||||
| _ -> None)
|
||||
|
@ -185,11 +185,11 @@ let () = register0 Services.Context.Nonce.hash nonce_hash
|
||||
(*-- Context.Key -------------------------------------------------------------*)
|
||||
|
||||
let get_key ctxt hash () =
|
||||
Public_key.get ctxt hash >>=? fun pk ->
|
||||
Delegates_pubkey.get ctxt hash >>=? fun pk ->
|
||||
return (hash, pk)
|
||||
|
||||
let () = register2 Services.Context.Key.get get_key
|
||||
let () = register0 Services.Context.Key.list Public_key.list
|
||||
let () = register0 Services.Context.Key.list Delegates_pubkey.list
|
||||
|
||||
(*-- Context.Contract --------------------------------------------------------*)
|
||||
|
||||
@ -469,7 +469,7 @@ let operation_public_key ctxt = function
|
||||
| None -> return None
|
||||
| Some public_key ->
|
||||
let hash = Ed25519.Public_key.hash public_key in
|
||||
Public_key.get_option ctxt hash >>=? function
|
||||
Delegates_pubkey.get_option ctxt hash >>=? function
|
||||
| None -> return (Some public_key)
|
||||
| Some _ -> return None
|
||||
|
||||
@ -499,7 +499,7 @@ let check_signature ctxt signature shell contents =
|
||||
| Some key -> return key
|
||||
| None ->
|
||||
Contract.get_manager ctxt op.source >>=? fun manager ->
|
||||
Public_key.get ctxt manager
|
||||
Delegates_pubkey.get ctxt manager
|
||||
end >>=? fun public_key ->
|
||||
Operation.check_signature public_key
|
||||
{ signature ; shell ; contents ; hash = dummy_hash }
|
||||
|
@ -87,7 +87,7 @@ module Constants = struct
|
||||
constants.dictator_pubkey
|
||||
end
|
||||
|
||||
module Public_key = Public_key_storage
|
||||
module Delegates_pubkey = Public_key_storage
|
||||
|
||||
module Voting_period = Voting_period_repr
|
||||
|
||||
|
@ -282,7 +282,8 @@ module Constants : sig
|
||||
|
||||
end
|
||||
|
||||
module Public_key : sig
|
||||
(** Global storage for all delegates public keys *)
|
||||
module Delegates_pubkey : sig
|
||||
|
||||
val get:
|
||||
context -> public_key_hash -> public_key tzresult Lwt.t
|
||||
|
Loading…
Reference in New Issue
Block a user