Blockchain 无法从hyperledger区块链中部署的合同中读取值

Blockchain 无法从hyperledger区块链中部署的合同中读取值,blockchain,hyperledger,Blockchain,Hyperledger,我已经在本地建立了hyperledger区块链。我在docker容器中运行hyperledger bc服务。我能够成功地启动节点,能够使用 但是无法从区块链中读回数据。下面是bc抛出的错误消息。谁能告诉我这里出了什么问题吗 [ibc-js] Deploy Chaincode - Complete {"query":{},"invoke":{},"details":{"deployed_name":"c123c14a65a511ee79e2a41b23726f473478d002064c0

我已经在本地建立了hyperledger区块链。我在docker容器中运行hyperledger bc服务。我能够成功地启动节点,能够使用

但是无法从区块链中读回数据。下面是bc抛出的错误消息。谁能告诉我这里出了什么问题吗

    [ibc-js] Deploy Chaincode - Complete
{"query":{},"invoke":{},"details":{"deployed_name":"c123c14a65a511ee79e2a41b23726f473478d002064c01c3ce035cffa1229af083d73f1db220fc2f267b9ae31d66ce2e10113548e7abdf8812986ac3c5770a9c","func":{"invoke":["init","write"],"query":["read"]},"git_url":"https://github.com/IBM-Blockchain/learn-chaincode/finished","options":{"quiet":true,"timeout":60000,"tls":false},"peers":[{"name":"vp0-vp0...:49155","api_host":"127.0.0.1","api_port":49155,"id":"vp0","tls":false}],"timestamp":1470146338831,"users":[],"unzip_dir":"learn-chaincode-master/finished","version":"github.com/hyperledger/fabric/core/chaincode/shim","zip_url":"https://github.com/IBM-Blockchain/learn-chaincode/archive/master.zip"}}
sdk has deployed code and waited
[ibc-js] write  - success: { jsonrpc: '2.0',
  result:
   { status: 'OK',
     message: '8b340e92-f96f-41f6-9b15-6ccb23304360' },
  id: 1470146405598 }
write response: { jsonrpc: '2.0',
  result:
   { status: 'OK',
     message: '8b340e92-f96f-41f6-9b15-6ccb23304360' },
  id: 1470146405598 }
    [ibc-js] read  - success: { jsonrpc: '2.0',
      error:
       { code: -32003,
         message: 'Query failure',
         data: 'Error when querying chaincode: Error:Failed to launch chaincode spec(Could not get deployment transaction for c123c14a65a511ee79e2xxxxxxxxxxxxxxxxe7abdf8812986ac3c5770a9c - LedgerError - ResourceNotFound: ledger: resource not found)' },
      id: 1470146405668 }
    read response: null { name: 'query() resp error',
      code: 400,
      details:
       { code: -32003,
         message: 'Query failure',
         data: 'Error when querying chaincode: Error:Failed to launch chaincode spec(Could not get deployment transaction for c123c14a65a511ee79e2xxxxxxxxxxxxxxxxe7abdf8812986ac3c5770a9c - LedgerError - ResourceNotFound: ledger: resource not found)' } }
我使用IBM区块链JS与go合同进行交互。 下面是节点js代码

// Step 1 ==================================
var Ibc1 = require('ibm-blockchain-js');
var ibc = new Ibc1(/*logger*/);             //you can pass a logger such as winston here - optional
var chaincode = {};


// ==================================
// configure ibc-js sdk
// ==================================
var options =   {
    network:{
        peers:   [{
            "api_host": "127.0.0.1",
            "api_port": 49155,
            //"api_port_tls": 49157,
            "id": "vp4"
        }],
        users: null,
        options: {quiet: true, tls:false, maxRetry: 1}
    },
    chaincode:{
        zip_url: 'https://github.com/IBM-Blockchain/learn-chaincode/archive/master.zip',
        unzip_dir: 'learn-chaincode-master/finished',    
        git_url: 'https://github.com/IBM-Blockchain/learn-chaincode/finished'

    }
};

// Step 2 ==================================
ibc.load(options, cb_ready);

// Step 3 ==================================
function cb_ready(err, cc){                             //response has chaincode functions

chaincode = cc;

   console.log(JSON.stringify(cc));

   chaincode.deploy('init', ['Hi hyperledger'], null, cb_deployed);


// Step 5 ==================================
function cb_deployed(){

    console.log(JSON.stringify(chaincode));
    console.log('sdk has deployed code and waited');

    console.log('******** Writing to chaincode Now **********');
    chaincode.invoke.write(["mykey","Hi Ledger Systems"],function(err,data){
    console.log('write response:', data);

   readData();


});
}



function readData()
{

console.log('\n\n**** Waiting 7 seconds before reading **** \n\n');
setTimeout(function () {
  console.log('\n\n**** Start reading **** \n\n');

  chaincode.invoke.read(["mykey"],function(err,data){
   console.log('read response:', data);

 });
}, 7000)
}


  }

指向链码的链接已断开,指向不存在的页面。请在问题中张贴链码-或至少相关的查询方法。我怀疑这可能是因为chaincode在查询方法中遇到错误,这迫使chaincode停止运行,但无法在不访问链码的情况下验证这一点。以下是CC部署名称@DavisBroda
C123C14A65A511EE79E2A41B23726F4738D002064C01C01C3CE035CFA1229AF083D73F1DB220FC2F267B9AE31D66CE2E10113548E7ABDF8812986AC3C5770A9C
chaincode.invoke.write([“mykey”,“插入的样本数据”]chaincode.query.read([“mykey”])\n我正在使用[github.com/IBM Blockchain/IBM Blockchain js]IBM Block Chain JS节点模块,用于部署、编写和查询链码。请注意,我正在本地运行该实例,您可能无法连接到我的CC。请将相关代码编辑到问题中,而不是将其放入注释中。当它出现在注释中时,很难阅读。此外,我要求的是链码,而不是js、 链码应该用Go编写,看起来应该是这样的。请发布链码中的查询方法,以及您提交的输入。此外,我不需要连接到您的链码,我需要查看源代码。您好@DavisBroda,我已修改了问题。添加了与contract交互的nodejs代码。Hyper为已部署的Go合同提供链接。首先,您正在执行
chaincode.invoke.read
而不是
chaincode.query.read
。鉴于read是一种查询方法,这可能会导致问题。但它可能不会导致此特定问题。从我的阅读来看,部署事务似乎失败了。您是不是绝对确保它部署/写入正确?如果是,你怎么知道?你是否直接查询了块并查看发生了什么?也许可以尝试从postman提交部署/写入/读取,这样你就可以确定这是cc问题还是javascript问题。你指向链码的链接已断开,指向一个不存在的页面。请发布问题中的chaincode-或至少是相关的查询方法。我怀疑这可能是因为chaincode在查询方法中遇到了错误,这迫使chaincode停止运行,但在没有访问chaincode的情况下无法验证。以下是CC部署名称@DavisBroda
C123C14A65A511EE79E2A41B23726F4738D002064C01c3ce035cffa1229af083d73f1db220fc2f267b9ae31d66ce2e10113548e7abdf8812986ac3c5770a9c
chaincode.invoke.write([“mykey”,“插入的样本数据”]chaincode.query.read([“mykey”]\n我正在使用[github.com/IBM Blockchain/IBM Blockchain js]IBM Block Chain JS节点模块,用于部署、编写和查询链码。请注意,我正在本地运行该实例,您可能无法连接到我的CC。请将相关代码编辑到问题中,而不是将其放入注释中。当它出现在注释中时,很难阅读。此外,我要求的是链码,而不是js、 链码应该用Go编写,看起来应该是这样的。请发布链码中的查询方法,以及您提交的输入。此外,我不需要连接到您的链码,我需要查看源代码。您好@DavisBroda,我已修改了问题。添加了与contract交互的nodejs代码。Hyper为已部署的Go合同提供链接。首先,您正在执行
chaincode.invoke.read
而不是
chaincode.query.read
。鉴于read是一种查询方法,这可能会导致问题。但它可能不会导致此特定问题。从我的阅读来看,部署事务似乎失败了。您是不是绝对确保它部署/写入正确?如果是,您如何知道?您是否直接查询了块并查看发生了什么?也许可以尝试从postman提交部署/写入/读取,以便您可以确定这是cc问题还是javascript问题。