首页 > 解决方案 > 在 Hyperledger 作曲家中特定天数后发出事件

问题描述

模型文件中称为Contracthavecontract_start_datecontract_end_dateproperties 的资产。我想在contract_end_date.

模型文件:

asset Contract identified by contractId {
       o String contractId
       o DateTime contract_start_date
       o DateTime contract_end_date
}

transaction set_Dates {
    --> Contract contract
    o DateTime start_date
    o DateTime end_date
}

event end_Date_Reached { 
    o String message
}

/** 
 * In the logic.js file 
 */
 
 async function setDate (tx) { 
   tx.contract.contract_start_date = tx.start_date;
   tx.contract.contract_end_date = tx.end_date; 
   
   // get the Contract asset from registry
  let contractRegistry = await getAssetRegistry('org.test.sample.Contract');
  await contractRegistry.update(tx.contract);  // update the registry
 }

如何end_Date_Reached通过检查contract_end_date属性的值来发出事件?任何帮助将不胜感激!

标签: node.jshyperledgerhyperledger-composer

解决方案


推荐阅读