Skip to content

Commit

Permalink
Bump env for bump interface changes (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh authored Aug 24, 2023
1 parent 67d95ad commit 3f55de1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ soroban-token-sdk = { version = "0.9.2", path = "soroban-token-sdk" }
[workspace.dependencies.soroban-env-common]
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
rev = "a4fe7a118131e11e1d78ba0e6627cfe72d7de2ad"
rev = "3be35df3061d08cf3e207b3eb546aa29adf32c01"

[workspace.dependencies.soroban-env-guest]
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
rev = "a4fe7a118131e11e1d78ba0e6627cfe72d7de2ad"
rev = "3be35df3061d08cf3e207b3eb546aa29adf32c01"

[workspace.dependencies.soroban-env-host]
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
rev = "a4fe7a118131e11e1d78ba0e6627cfe72d7de2ad"
rev = "3be35df3061d08cf3e207b3eb546aa29adf32c01"

[workspace.dependencies.stellar-strkey]
version = "0.0.7"
Expand Down
37 changes: 26 additions & 11 deletions soroban-sdk/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,22 @@ impl Storage {
.unwrap_infallible();
}

pub(crate) fn bump<K>(&self, key: &K, storage_type: StorageType, min_ledgers_to_live: u32)
where
pub(crate) fn bump<K>(
&self,
key: &K,
storage_type: StorageType,
low_expiration_watermark: u32,
high_expiration_watermark: u32,
) where
K: IntoVal<Env, Val>,
{
let env = &self.env;
internal::Env::bump_contract_data(
env,
key.into_val(env),
storage_type,
min_ledgers_to_live.into(),
low_expiration_watermark.into(),
high_expiration_watermark.into(),
)
.unwrap_infallible();
}
Expand Down Expand Up @@ -253,12 +259,16 @@ impl Persistent {
self.storage.set(key, val, StorageType::Persistent)
}

pub fn bump<K>(&self, key: &K, min_ledgers_to_live: u32)
pub fn bump<K>(&self, key: &K, low_expiration_watermark: u32, high_expiration_watermark: u32)
where
K: IntoVal<Env, Val>,
{
self.storage
.bump(key, StorageType::Persistent, min_ledgers_to_live)
self.storage.bump(
key,
StorageType::Persistent,
low_expiration_watermark,
high_expiration_watermark,
)
}

#[inline(always)]
Expand Down Expand Up @@ -299,12 +309,16 @@ impl Temporary {
self.storage.set(key, val, StorageType::Temporary)
}

pub fn bump<K>(&self, key: &K, min_ledgers_to_live: u32)
pub fn bump<K>(&self, key: &K, low_expiration_watermark: u32, high_expiration_watermark: u32)
where
K: IntoVal<Env, Val>,
{
self.storage
.bump(key, StorageType::Temporary, min_ledgers_to_live)
self.storage.bump(
key,
StorageType::Temporary,
low_expiration_watermark,
high_expiration_watermark,
)
}

#[inline(always)]
Expand Down Expand Up @@ -353,10 +367,11 @@ impl Instance {
self.storage.remove(key, StorageType::Instance)
}

pub fn bump(&self, min_ledgers_to_live: u32) {
pub fn bump(&self, low_expiration_watermark: u32, high_expiration_watermark: u32) {
internal::Env::bump_current_contract_instance_and_code(
&self.storage.env,
min_ledgers_to_live.into(),
low_expiration_watermark.into(),
high_expiration_watermark.into(),
)
.unwrap_infallible();
}
Expand Down
6 changes: 3 additions & 3 deletions soroban-sdk/src/tests/contract_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ impl Contract {
}

pub fn bump_persistent(env: Env, k: i32) {
env.storage().persistent().bump(&DataKey::Key(k), 100);
env.storage().persistent().bump(&DataKey::Key(k), 100, 100);
}

pub fn bump_temporary(env: Env, k: i32) {
env.storage().temporary().bump(&DataKey::Key(k), 100);
env.storage().temporary().bump(&DataKey::Key(k), 100, 100);
}

pub fn bump_instance(env: Env) {
env.storage().instance().bump(100);
env.storage().instance().bump(100, 100);
}
}

Expand Down

0 comments on commit 3f55de1

Please sign in to comment.