Alpha_002: forced registration for unregistered delegates

This commit is contained in:
Pierre Chambart 2018-07-17 18:24:58 +02:00 committed by Grégoire Henry
parent 15857d7e90
commit cff6c4beb1

View File

@ -44,7 +44,28 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness =
Storage.Last_block_priority.init ctxt 0 >>=? fun ctxt -> Storage.Last_block_priority.init ctxt 0 >>=? fun ctxt ->
return ctxt return ctxt
| Alpha -> | Alpha ->
return ctxt Storage.Contract.fold ctxt ~init:(ok ctxt)
~f:(fun contract ctxt ->
Lwt.return ctxt >>=? fun ctxt ->
match contract with
| Implicit _ -> return ctxt
| Originated _contract_hash ->
Roll_storage.get_contract_delegate ctxt contract >>=? fun delegate ->
match delegate with
| None -> return ctxt
| Some delegate ->
Delegate_storage.registered ctxt delegate >>= fun registered ->
if registered then
return ctxt
else
Contract_storage.is_manager_key_revealed
ctxt (Contract_repr.implicit_contract delegate) >>=? fun revealed ->
if revealed then
Delegate_storage.set ctxt
(Contract_repr.implicit_contract delegate)
(Some delegate)
else
return ctxt)
let prepare ctxt ~level ~timestamp ~fitness = let prepare ctxt ~level ~timestamp ~fitness =
Raw_context.prepare ~level ~timestamp ~fitness ctxt Raw_context.prepare ~level ~timestamp ~fitness ctxt