mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
fix storage-provider.fc
This commit is contained in:
parent
a1d2d7cb04
commit
bdd0c1e035
1 changed files with 29 additions and 3 deletions
|
@ -43,6 +43,32 @@ cell build_storage_contract_stateinit(int merkle_hash, int file_size, int rate_p
|
||||||
return state_init;
|
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,
|
() 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 {
|
int expected_rate, int expected_max_span) impure {
|
||||||
var ds = get_data().begin_parse();
|
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);
|
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();
|
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);
|
return calculate_address_by_stateinit(state_init);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue