Skip to content

Commit

Permalink
fix: add definitions about lock and cancel lock
Browse files Browse the repository at this point in the history
  • Loading branch information
raindust committed Dec 26, 2023
1 parent b5ca22a commit e2a9446
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions system-actors/src/keyvalue/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ pub struct DelResponse {
pub key: String,
}

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId, Priced)]
#[price(30000)]
#[response(())]
pub struct LockRequest {
pub key: String,
pub expires_s: Option<i32>,
}

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId, Priced)]
#[price(10000)]
#[response(())]
pub struct CancelLockRequest {
pub key: String,
}

#[doc(hidden)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeId, Priced)]
#[price(10000)]
Expand Down
17 changes: 17 additions & 0 deletions utils/wasm-actor-utils/src/enclave/actors/kvp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ pub async fn del(key: &str) -> Result<String> {
Ok(r.key)
}

pub async fn lock(key: &str, expires_s: Option<i32>) -> Result<()> {
let req = LockRequest {
key: key.to_owned(),
expires_s,
};
KVP_ACTOR.call(req).await?;
Ok(())
}

pub async fn cancel_lock(key: &str) -> Result<()> {
let req = CancelLockRequest {
key: key.to_owned(),
};
KVP_ACTOR.call(req).await?;
Ok(())
}

#[doc(hidden)]
pub async fn add(key: &str, value: i32) -> Result<i32> {
let req = AddRequest {
Expand Down

0 comments on commit e2a9446

Please sign in to comment.