错误:任何对等方均未提供有效响应。尝试对等通信的响应是错误的

时间:2019-04-05 21:13:31

标签: hyperledger-composer

每次提交交易时都会遇到此特定错误:

  

错误:尝试调用事务ID为bcffe477a38ba39c6bcbea6324e87903c54e609b31030df6b0b41ed2859906f2的业务网络时出错。错误:任何对等方均未提供有效响应。来自对等通信尝试的响应是一个错误:错误:事务返回失败:TypeError:无法读取未定义的属性'value'

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
}

预期的输出为oldValue为50,但我们得到了错误。

0 个答案:

没有答案