Skip to content

Commit

Permalink
Update extend_ttl docs (#1217)
Browse files Browse the repository at this point in the history
### What

Add missing docs
  • Loading branch information
sisuresh authored Jan 31, 2024
1 parent 6e198b7 commit 63e865e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
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

0 comments on commit 63e865e

Please sign in to comment.