Proto: refill bootstrap contracts at the end of a cycle
This commit is contained in:
parent
55e2429758
commit
c8376198c8
@ -190,6 +190,7 @@ let may_start_new_cycle ctxt =
|
||||
>>=? fun reward_date ->
|
||||
Reward.set_reward_time_for_cycle
|
||||
ctxt last_cycle reward_date >>=? fun ctxt ->
|
||||
Bootstrap.refill ctxt >>=? fun ctxt ->
|
||||
return ctxt
|
||||
|
||||
let apply_main ctxt accept_failing_script block operations =
|
||||
|
@ -98,3 +98,14 @@ let account_encoding =
|
||||
(req "publicKey" Ed25519.public_key_encoding)
|
||||
(req "secretKey" Ed25519.secret_key_encoding))
|
||||
|
||||
let refill ctxt =
|
||||
fold_left_s
|
||||
(fun ctxt account ->
|
||||
let contract =
|
||||
Contract_repr.default_contract account.public_key_hash in
|
||||
Contract_storage.get_balance ctxt contract >>=? fun balance ->
|
||||
match Tez_repr.(wealth -? balance) with
|
||||
| Error _ -> return ctxt
|
||||
| Ok tez -> Contract_storage.credit ctxt contract tez)
|
||||
ctxt
|
||||
accounts
|
||||
|
@ -18,3 +18,5 @@ val account_encoding: account Data_encoding.t
|
||||
val accounts: account list
|
||||
|
||||
val init: Storage.t -> Storage.t tzresult Lwt.t
|
||||
|
||||
val refill: Storage.t -> Storage.t tzresult Lwt.t
|
||||
|
@ -163,6 +163,7 @@ module Bootstrap : sig
|
||||
}
|
||||
val accounts: account list
|
||||
val account_encoding: account Data_encoding.t
|
||||
val refill: context -> context tzresult Lwt.t
|
||||
end
|
||||
|
||||
module Constants : sig
|
||||
|
Loading…
Reference in New Issue
Block a user