2016-09-27 74 views
1

我得到這個我認爲很常見的錯誤"..LedgerError - ResourceNotFound: ledger: resource not found" .如何調試chaincode? LedgerError - ResourceNotFound

爲簡單起見,這就是我:

  1. 儘量簡單chaincode,給定chaincode_example02.go

  2. 開啓off security因此沒有CA (CORE_SECURITY_ENABLED=false CORE_SECURITY_PRIVACY=falss)

  3. 只有1個對等節點(使用0.5版本),它是一個對等實例克爾圖像

  4. 在開發模式下運行

我這是怎麼部署在開發模式的代碼,請不要驗證如果CLI是正確的:

CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./chaincode_example02 

,它顯示

'Received REGISTERED, ready for invocations' 

現在試圖查詢它,請確認這個cli是否正確:

peer chaincode query -n mycc -c '{"Function": "query", "Args": ["b"]}' 

,但返回的錯誤是:

Error: Error querying chaincode: rpc error: code = 2 desc = "Error:Failed to launch chaincode spec(Could not get deployment transaction for chaincode_example02 - LedgerError - ResourceNotFound: ledger: resource not found)" 

任何想法?我檢查了/var下的所有日誌,但沒有發現任何有用的東西,也檢查了/var/hyperledger,並確實在/var/hyperledger/production/db下看到了一些更新。

這個試驗看起來非常直截了當,但出人意料地發生了一個錯誤。

..所以我該如何去調試呢?

回答

0

下面的命令,

CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./chaincode_example02 

deploy的chaincode,它簡單地開始並註冊與驗證對等體的chaincode。

一旦它被註冊,你需要deploy然後invoke它之前,你可以query

如上所述here

First, send a chaincode deploy transaction, only once, to the validating peer. The CLI connects to the validating peer using the properties defined in the core.yaml file. Note: The deploy transaction typically requires a path parameter to locate, build, and deploy the chaincode. However, because these instructions are specific to local development mode and the chaincode is deployed manually, the name parameter is used instead.

peer chaincode deploy -n mycc -c '{"Function":"init", "Args": ["a","100", "b", "200"]}' 

一旦部署,你可以調用它,你要儘可能多的時間,然後query調用的交易,

invoke

peer chaincode invoke -l golang -n mycc -c '{"Function": "invoke", "Args": ["a", "b", "10"]}' 

query

peer chaincode query -l golang -n mycc -c '{"Function": "query", "Args": ["b"]}' 

另外,還要確保你有運行在一個終端peer,運行在第二終端的chaincode,同時部署,調用和第三個查詢交易。

+0

好吧,我做了一個部署,它返回一個很長的數字,然後再次調用它返回一些數字,然後最終做了一個查詢,但它仍然返回相同的錯誤。怎麼辦?還有幾個問題:1)-n選項值應該是'mycc'用於部署,調用和查詢? 2)有沒有我可以看到的日誌文件? 3)標準輸出文件在哪裏,即'fmt.Printf'輸出到哪裏? – Tara

+0

-n本意是一個事務ID,但是當你在開發模式下運行時,你不需要它。你在開發模式下運行嗎? –

+0

是的開發模式,你可以先回答我的三個問題。我也確實看到爲我的已部署鏈代碼創建了一個新的docker容器..所以請指教下一步是什麼? – Tara