Просмотр исходного кода

smart-contract: Add note about deleting sled trees on failures.

parazyd 3 лет назад
Родитель
Сommit
f6296bf3f2
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      example/smart-contract/src/lib.rs

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

@@ -56,13 +56,16 @@ define_contract!(
     init: init_contract,
     init: init_contract,
     exec: process_instruction,
     exec: process_instruction,
     apply: process_update,
     apply: process_update,
-
     metadata: get_metadata
     metadata: get_metadata
 );
 );
 
 
 fn init_contract(cid: ContractId, _ix: &[u8]) -> ContractResult {
 fn init_contract(cid: ContractId, _ix: &[u8]) -> ContractResult {
     msg!("wakeup wagies!");
     msg!("wakeup wagies!");
     db_init(cid, "wagies")?;
     db_init(cid, "wagies")?;
+    // TODO: If the deploy execution fails, whatever is initialized with db_init
+    //       should be deleted from sled afterwards. There's no way to create a
+    //       tree but only apply the creation when we're done, so db_init creates
+    //       it and upon failure it should delete it
 
 
     // Lets write a value in there
     // Lets write a value in there
     let tx_handle = db_begin_tx()?;
     let tx_handle = db_begin_tx()?;
@@ -148,4 +151,3 @@ fn process_update(_cid: ContractId, update_data: &[u8]) -> ContractResult {
 
 
     Ok(())
     Ok(())
 }
 }
-