首页 > 解决方案 > 错误:没有来自任何对等方的有效响应。来自尝试的对等通信的响应是错误的

问题描述

每次提交交易时,我都会收到此特定错误:

错误:尝试使用事务 id bcffe477a38ba39c6bcbea6324e87903c54e609b31030df6b0b41ed2859906f2 调用业务网络时出错。错误:没有来自任何对等方的有效响应。来自尝试的对等通信的响应是一个错误:错误:事务返回失败:TypeError:无法读取未定义的属性“值”

namespace org.example.basic

asset SampleAccount identified by accountId {
o String accountId
--> SampleParticipant owner
o Double value
}



participant SampleParticipant identified by participantId {
  o String participantId
  o String firstName
  o String lastName
}



transaction SampleTransaction {
  --> SampleAccount account
  o Double newValue
}



event SampleEvent {
  --> SampleAccount account
  o Double oldValue
  o Double newValue
}


async function sampleTransaction(tx) {  // eslint-disable-line no-unused-vars

// Save the old value of the asset.
let oldValue = tx.asset.value;
// Update the asset with the new value.
tx.asset.value += tx.newValue;



// Get the asset registry for the asset.
let assetRegistry = getAssetRegistry('org.example.basic.SampleAsset');
// Update the asset in the asset registry.
await assetRegistry.update(tx.asset);

// Emit an event for the modified asset.
let event = getFactory().newEvent('org.example.basic', 'SampleEvent');
event.asset = tx.asset;
event.oldValue = oldValue;
event.newValue = tx.newValue;
emit(event);
}




rule EverybodyCanReadEverything {
    description: "Allow all participants read access to all resources"
    participant: "org.example.basic.SampleParticipant"
    operation: READ
    resource: "org.example.basic.*"
    action: ALLOW
}



rule EverybodyCanSubmitTransactions {
    description: "Allow all participants to submit transactions"
    participant: "org.example.basic.SampleParticipant"
    operation: CREATE
    resource: "org.example.basic.SampleTransaction"
    action: ALLOW  
}



rule OwnerHasFullAccessToTheirAssets {
    description: "Allow all participants full access to their assets"
    participant(p): "org.example.basic.SampleParticipant"
    operation: ALL
    resource(r): "org.example.basic.SampleAccount"
    condition: (r.owner.getIdentifier() === p.getIdentifier())
    action: ALLOW
}



rule SystemACL {
    description: "System ACL to permit all access"
    participant: "org.hyperledger.composer.system.Participant"
    operation: ALL
    resource: "org.hyperledger.composer.system.**"
    action: ALLOW
}



rule NetworkAdminUser {

    description: "Grant business network administrators full access to user resources"
    participant: "org.hyperledger.composer.system.NetworkAdmin"
    operation: ALL
    resource: "**"
    action: ALLOW
}



rule NetworkAdminSystem {

    description: "Grant business network administrators full access to system resources"
    participant: "org.hyperledger.composer.system.NetworkAdmin"
    operation: ALL
    resource: "org.hyperledger.composer.system.**"
    action: ALLOW
}

数据输入如下:

{
  "$class": "org.example.basic.SampleTransaction",
  "account": "resource:org.example.basic.SampleAccount#123",
  "newValue": 50
}

预期的输出是oldValue50,但我们得到了错误。

标签: hyperledger-composer

解决方案


推荐阅读