Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update extend_ttl docs #1217

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions soroban-sdk/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ impl Deployer {
.unwrap_infallible();
}

/// Extend the TTL of the contract instance.
/// Extend the TTL of the contract instance and code.
///
/// Extends the TTL only if the TTL for the provided contract is below `threshold` ledgers.
/// Extends the TTL of the instance and code only if the TTL for the provided contract is below `threshold` ledgers.
/// The TTL will then become `extend_to`. Note that the `threshold` check and TTL extensions are done for both the
/// contract code and contract instance, so it's possible that one is bumped but not the other depending on what the
/// current TTL's are.
///
/// The TTL is the number of ledgers between the current ledger and the `live_until_ledger_seq` value for the ledger entry.
/// The TTL is the number of ledgers between the current ledger and the final ledger the data can still be accessed.
pub fn extend_ttl(&self, contract_address: Address, threshold: u32, extend_to: u32) {
self.env
.extend_contract_instance_and_code_ttl(
Expand Down
20 changes: 20 additions & 0 deletions soroban-sdk/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ impl Persistent {
self.storage.try_update(key, StorageType::Persistent, f)
}

/// Extend the TTL of the data under the key.
///
/// Extends the TTL only if the TTL for the provided data is below `threshold` ledgers.
/// The TTL will then become `extend_to`.
///
/// The TTL is the number of ledgers between the current ledger and the final ledger the data can still be accessed.
pub fn extend_ttl<K>(&self, key: &K, threshold: u32, extend_to: u32)
where
K: IntoVal<Env, Val>,
Expand Down Expand Up @@ -445,6 +451,12 @@ impl Temporary {
self.storage.try_update(key, StorageType::Temporary, f)
}

/// Extend the TTL of the data under the key.
///
/// Extends the TTL only if the TTL for the provided data is below `threshold` ledgers.
/// The TTL will then become `extend_to`.
///
/// The TTL is the number of ledgers between the current ledger and the final ledger the data can still be accessed.
pub fn extend_ttl<K>(&self, key: &K, threshold: u32, extend_to: u32)
where
K: IntoVal<Env, Val>,
Expand Down Expand Up @@ -536,6 +548,14 @@ impl Instance {
self.storage.remove(key, StorageType::Instance)
}

/// Extend the TTL of the contract instance and code.
///
/// Extends the TTL of the instance and code only if the TTL for the provided contract is below `threshold` ledgers.
/// The TTL will then become `extend_to`. Note that the `threshold` check and TTL extensions are done for both the
/// contract code and contract instance, so it's possible that one is bumped but not the other depending on what the
/// current TTL's are.
///
/// The TTL is the number of ledgers between the current ledger and the final ledger the data can still be accessed.
pub fn extend_ttl(&self, threshold: u32, extend_to: u32) {
internal::Env::extend_current_contract_instance_and_code_ttl(
&self.storage.env,
Expand Down
Loading