交易为什么会出现此错误 [英] Why does transaction give this error

查看:93
本文介绍了交易为什么会出现此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的model.cto文件-

My model.cto file -

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文件

My Script.js file

/**
* 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);
  })
}

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

I'm using online playground. Submitting this transaction gives me an error:

找不到用于事务org.acme.mynetwork.GenerateRFQ#ae28a855-ba3c-48fe-9404-291ad95b24c7的任何函数

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

我曾尝试更改其名称,但仍然没有效果.但是SampleTransaction业务逻辑工作正常.

I've tried changing its name but still no good. However SampleTransaction business logic is working fine.

推荐答案

您的问题是,您尚未为名为 GenerateRFQ 的事务(在.cto文件中)建模,如下所示: org .acme.mynetwork.GenerateRFQ 在装饰器中.

your problem is that you have not modeled a transaction (in your .cto file) called GenerateRFQ as in: org.acme.mynetwork.GenerateRFQ in your decorator.

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

So add the following (below) to your model file - then do a composer network update to update your business network (and chaincode) to recognise the newly modeled transaction (that you call in your script).

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

我在您的脚本中注意到了一个问题(该问题必须在您的网络项目的/lib子目录下).您分配一个new Date()-这是不确定性代码,因此执行此操作的每个对等方都将执行'date'功能并获得不同的时间戳.

There is one issue I noticed in your script (which needs to be under the /lib subdirectory of your network project). You assign a new Date() - this is non-deterministic code, so each peer that would execute this will execute the 'date' function and get a different timestamp.

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

Also - other things that you may wish to consider - (based on the model you posted here):

客户应该与经纪人有关系-在此处查看示例网络->

Clients should be a relationship to Broker - see a sample network here -> 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

这篇关于交易为什么会出现此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆