From bdd0c1e0351386dc5e1eb0f2e95585d75ec0d1f5 Mon Sep 17 00:00:00 2001 From: Admin Date: Wed, 25 Oct 2023 19:53:03 +0400 Subject: [PATCH] fix storage-provider.fc --- .../smartcont/storage-provider.fc | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/storage/storage-daemon/smartcont/storage-provider.fc b/storage/storage-daemon/smartcont/storage-provider.fc index 07d6b563a..1ced8c7a5 100644 --- a/storage/storage-daemon/smartcont/storage-provider.fc +++ b/storage/storage-daemon/smartcont/storage-provider.fc @@ -43,6 +43,32 @@ cell build_storage_contract_stateinit(int merkle_hash, int file_size, int rate_p return state_init; } +cell calculate_storage_contract_stateinit(int merkle_hash, int file_size, int rate_per_mb_day, + int max_span, int last_proof_time, slice client, int torrent_hash) { + cell data = begin_cell() + .store_int(0, 1) ;; active + .store_coins(0) ;; client balance + .store_slice(my_address()) + .store_uint(merkle_hash, 256) + .store_uint(file_size, 64) + .store_uint(0, 64) ;; next_proof + .store_coins(rate_per_mb_day) + .store_uint(max_span, 32) + .store_uint(last_proof_time, 32) ;; last_proof_time + .store_ref(begin_cell() + .store_slice(client) + .store_uint(torrent_hash, 256) + .end_cell()) + .end_cell(); + + cell state_init = begin_cell() + .store_uint(0, 2) + .store_maybe_ref(storage_contract_code()) + .store_maybe_ref(data) + .store_uint(0, 1) .end_cell(); + return state_init; +} + () deploy_storage_contract (slice client, int query_id, int file_size, int merkle_hash, int torrent_hash, int expected_rate, int expected_max_span) impure { var ds = get_data().begin_parse(); @@ -223,8 +249,8 @@ _ get_storage_params() method_id { return (accept_new_contracts?, rate_per_mb_day, max_span, minimal_file_size, maximal_file_size); } -slice get_storage_contract_address(int merkle_hash, int file_size, slice client, int torrent_hash) method_id { +slice get_storage_contract_address(int merkle_hash, int file_size, int last_proof_time, slice client, int torrent_hash) method_id { var (_, rate_per_mb_day, max_span, _, _) = get_storage_params(); - cell state_init = build_storage_contract_stateinit(merkle_hash, file_size, rate_per_mb_day, max_span, client, torrent_hash); + cell state_init = calculate_storage_contract_stateinit(merkle_hash, file_size, rate_per_mb_day, max_span, last_proof_time, client, torrent_hash); return calculate_address_by_stateinit(state_init); -} +} \ No newline at end of file