瀏覽代碼

remove get access from update and deploy functions

x 3 年之前
父節點
當前提交
f2aac746cb
共有 2 個文件被更改,包括 5 次插入6 次删除
  1. 4 5
      example/smart-contract/src/lib.rs
  2. 1 1
      src/runtime/import/db.rs

+ 4 - 5
example/smart-contract/src/lib.rs

@@ -165,9 +165,9 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
             }
         }
         Function::Bar => {
-            let tx_data = &ix[1..];
+            //let tx_data = &ix[1..];
             // ...
-            let _args: BarArgs = deserialize(tx_data)?;
+            //let _args: BarArgs = deserialize(tx_data)?;
         }
     }
 
@@ -178,7 +178,6 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
 fn process_update(_cid: ContractId, update_data: &[u8]) -> ContractResult {
     msg!("Make 1 update!");
 
-    /*
     match Function::from(update_data[0]) {
         Function::Foo => {
             msg!("fooupp");
@@ -190,9 +189,9 @@ fn process_update(_cid: ContractId, update_data: &[u8]) -> ContractResult {
             //let db_handle = db_lookup("wagies")?;
             //db_end_tx(db_handle, tx_handle)?;
         }
-        _ => unreachable!(),
+        Function::Bar => {
+        }
     }
-    */
 
     msg!("process_update() finished");
     Ok(())

+ 1 - 1
src/runtime/import/db.rs

@@ -286,7 +286,7 @@ pub(crate) fn db_set(ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>, len: u32) -> i3
 pub(crate) fn db_get(ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>, len: u32) -> i64 {
     let env = ctx.data();
     match env.contract_section {
-        ContractSection::Deploy | ContractSection::Exec | ContractSection::Update => {
+        ContractSection::Exec => {
             let memory_view = env.memory_view(&ctx);
             let db = &env.blockchain.sled_db;
             let contracts = &env.blockchain.contracts;