为什么交易会报这个错

Why does transaction give this error

我的 model.cto 文件 -

namespace org.acme.mynetwork

participant Client identified by ClientId {
  o String ClientId  
  o String ClientName
  o String[] Policies
  o String[] RFQAraay
}

participant Insurer identified by InsurerId {
  o String InsurerId  
  o String InsurerName
  o String[] RFQArray
  o String[] Quotes
  o String[] Policies
}

asset RFQ identified by RFQId {
  o String RFQId
  o String ClientId
  o String InsurerName
  o String TypeOfInsurance
  o String RiskAmunt
  o String Status
  o String currentOwner
  o String[] Quotes
  o String[] SelectedInsurer
  o String LeadInsurer
  o String[] FinalInsurer
}

participant Broker identified by BrokerId {
  o String BrokerId
  o String BrokerName
  o String[] Clients
}

asset Quote identified by QuoteId {
  o String QuoteId
  o String InsurerName
  o String InsurerId
  o String Premium
  o String Capacity
  o String RFQId
}

transaction GenerateRFQ {
  o String RFQId
  o String ClientId
  o String InsurerName
  o String TypeOfInsurance
  o String RiskAmount
  o String[] InsurerAddresses 
}

我的 Script.js 文件

/**
* Insurance script file
* @param {org.acme.mynetwork.GenerateRFQ} generate - the trade to be  processed
* @transaction
*/
function generateRFQ(generate){
  var RFQId = generate.RFQId ;
  var today = new Date();
  var y = today.getFullYear();
  var m = today.getMonth();
  var d = today.getDate();
  return getAssetRegistry('org.acme.mynetwork.RFQ').then(function(assetRegistry){
    var RFQregistry = assetRegistry;
    RFQregistry.RFQId = generate.RFQId; 
    RFQregistry.ClientId = generate.ClientId 
    RFQregistry.InsuredName = generate.InsurerName;
    RFQregistry.TypeOfInsurance = generate.TypeOfInsurance;
    RFQregistry.RiskAmount = generate.RiskAmount; 
    RFQregistry.Status = "RFQ fired on "+ d + m + y;
    RFQregistry. Insurer = generate.InsurerAddresses;
  return assetRegistry.update(RFQregistry);
  })
}

我正在使用在线游乐场。提交此交易给我一个错误:

Could not find any functions to execute for transaction org.acme.mynetwork.GenerateRFQ#ae28a855-ba3c-48fe-9404-291ad95b24c7

我试过更改它的名字,但还是不行。但是 SampleTransaction 业务逻辑运行良好。

您的问题是您没有为名为 GenerateRFQ 的交易建模(在您的 .cto 文件中),如:org.acme.mynetwork.GenerateRFQ 在你的装饰器中。

因此,将以下(下方)添加到您的模型文件 - 然后执行 composer network update 更新您的业务网络(和链代码)以识别新建模的交易(您在脚本中调用)。

transaction GenerateRFQ {
 ...add your model elements or relationships here
}

我在你的脚本中发现了一个问题(它需要在你的网络项目的 /lib 子目录下)。您分配一个 new Date() - 这是非确定性代码,因此每个执行此代码的对等方将执行 'date' 函数并获得不同的时间戳。

此外 - 您可能希望考虑的其他事项 -(基于您在此处发布的模型):

Clients 应该与 Broker 有关系 - 请在此处查看示例网络 -> https://github.com/hyperledger/composer-sample-networks/blob/master/packages/trade-network/models/trading.cto for an example of relationships. There may be in fact more relationships to consider in your model (eg one to many etc). Lastly your transaction should ideally have a relationship back to the participants and assets that are being 'referenced' in your code (eg. Client, Insurer etc). Again, look at the model file link I sent you to get an idea - also look at the other samples here -> https://github.com/hyperledger/composer-sample-networks/tree/master/packages for pointers and review the model language guide here -> https://hyperledger.github.io/composer/unstable/reference/cto_language.html