错误:具有ID'参与者的对象:com.test.participant'在ID' $ sysregistries'的集合中不存在

时间:2018-06-07 08:04:11

标签: hyperledger-composer

我正在尝试使用交易更改参与者的价值。 它会引发错误"错误:具有ID'参与者的对象:com.test.participant'在ID' $ sysregistries'的集合中不存在"

请告诉我这是什么问题。新版本有没有变化?

基础cto:

namespace com.test.base

enum Gender {
 o MALE
 o FEMALE
 o OTHER
}

/**
 * A concept for a simple street address
 */
concept Address {
  o String address
  o Boolean isAddressValidated 
}

参与者CTO:

/**
 * New model file
 */

namespace com.test.participant
import com.test.base.*

abstract participant User{
  o  String lastname
 }

participant Customer identified by userId extends User {
  o String userId 
  o String fName
  o Address address
}

transaction ValidateAddress {
  o Boolean isAddressValidated
  --> Customer customer
}

Js文件:

 /**
     * Sample transaction processor function.
     * @param {com.test.participant.ValidateAddress} tx The sample transaction instance.
     * @transaction
     */
    async function sampleTransaction(tx) { 
         tx.customer.address.isAddressValidated = tx.isAddressValidated;

        const participantRegistry = await getParticipantRegistry('com.test.participant','Costumer');
  await participantRegistry.update(tx.customer);

     }

测试值:

{
  "$class": "com.test.participant.Customer",
  "uId": "customer1",
  "fName": "Pradeep",
  "address": {
    "$class": "com.test.base.Address",
    "address": "",
    "isAddressValidated": false
  },
  "lastname": "P"
}

{
  "$class": "com.test.participant.ValidateAddress",
  "isAddressValidated": true,
  "customer": "resource:com.test.participant.Customer#customer1"
}

在链接中下载bna文件 https://drive.google.com/file/d/1NQYELmLzMyuN2V4yvDhUoLWackjs18Fa/view?usp=sharing

1 个答案:

答案 0 :(得分:2)

我在您的网络定义中编辑了two个内容,注意:我在Hyperldger Playground上进行了测试并且它可以正常工作

  1. 在测试数据中将uId更改为userId
  2. 在您获得参与者注册表的交易代码中清除客户拼写错误。
  3. 所以我在所有更改之后想出了这段代码

    namespace com.test.base
    
    enum Gender {
     o MALE
     o FEMALE
     o OTHER
    }
    
    /**
     * A concept for a simple street address
     */
    concept Address {
      o String address
      o Boolean isAddressValidated  
    }
    
    
    /**
     * New model file
    */
    
    namespace com.test.participant
    import com.test.base.*
    
    abstract participant User{
      o  String lastname
     }
    
    participant Customer identified by userId extends User {
      o String userId 
      o String fName
      o Address address
    }
    
    transaction ValidateAddress {
      o Boolean isAddressValidated
      --> Customer customer
    }
    

    测试数据如下所示

    {
      "$class": "com.test.participant.Customer",
      "userId": "customer1",
      "fName": "Pradeep",
      "address": {
        "$class": "com.test.base.Address",
        "address": "New York",
        "isAddressValidated": true
      },
      "lastname": "P"
    }
    

    对于交易 我什么都没改变。我希望这有帮助