Я пытаюсь получить chaincode_example02 от IBM работать, но я борюсь с некоторыми вопросамиBluemix: Ошибка: Не удалось запустить chaincode спецификации (не удалось получить сделку развертывания для
Я связан с сетью стартера Bluemix. . Я ждал дольше для запроса, но без успеха Теперь я читаю журнал пэра и у меня есть следующие вопросы:.
мне нужно сделать, чтобы добавить/импортировать пир и подкладку из моего локального пути рабочий каталог?
Что d oes
launchAndWaitForRegister failed Error starting container: API error (500)
означает?
OUT - 20:45:56.877 [consensus/pbft] ProcessEvent -> INFO 1ca[0m Replica 0 batch timer expired OUT - 20:45:56.877 [consensus/pbft] sendBatch -> INFO 1cb[0m Creating batch with 1 requests OUT - 20:45:56.879 [consensus/pbft] executeOne -> INFO 1cc[0m Replica 0 executing/committing request batch for view=0/seqNo=31 and digest YrYAFLUeCUaZSwV85WOvOzd8rDHIeryEt5612Tck8gjf+jVU+Xh1y+3OE+rpz08VPPSbbwt7vR0wsrU1NzvXoA== OUT - [31m20:45:58.930 [dockercontroller] deployImage -> ERRO 1cd[0m Error building images: The command '/bin/sh -c go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/8482db43feb10640d37c343bf6d50feb29ba21da196075a721d6489eb1fab616' returned a non-zero code: 1
OUT - [31m20:45:58.930 [dockercontroller] deployImage -> ERRO 1ce[0m Image Output: OUT - ******************** OUT - Step 1 : FROM hyperledger/fabric-baseimage OUT - ---> 21cb00fb27f4 OUT - Step 2 : COPY . $GOPATH/src/build-chaincode/ OUT - ---> Using cache OUT - ---> f4e8d401945d OUT - Step 3 : WORKDIR $GOPATH OUT - ---> Using cache OUT - ---> 4cb1d635a080 OUT - Step 4 : RUN go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/8482db43feb10640d37c343bf6d50feb29ba21da196075a721d6489eb1fab616 OUT - ---> Running in 85da9ebe80f0
OUT - [91msrc/build-chaincode/chaincode_example02.go:30:2: cannot find package "github.com/hyperledger/fabric/protos/peer" in any of: OUT - /opt/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT) OUT - /opt/gopath/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH) OUT - [0m OUT - ******************** OUT - [31m20:45:59.688 [dockercontroller] Start -> ERRO 1cf[0m start-could not recreate container API error (500): Error: image library/8b01ce9efeff42d48ce02c3c53356c1d-vp0-8482db43feb10640d37c343bf6d50feb29ba21da196075a721d6489eb1fab616:latest not found
OUT - [31m20:45:59.688 [chaincode] Launch -> ERRO 1d0[0m launchAndWaitForRegister failed Error starting container: API error (500): Error: image library/8b01ce9efeff42d48ce02c3c53356c1d-vp0-8482db43feb10640d37c343bf6d50feb29ba21da196075a721d6489eb1fab616:latest not found OUT - 20:45:59.689 [consensus/pbft] execDoneSync -> INFO 1d1[0m Replica 0 finished execution 31, trying next OUT - 20:47:56.546 [consensus/pbft] ProcessEvent -> INFO 1d2[0m Replica 0 batch timer expired OUT - 20:47:56.547 [consensus/pbft] sendBatch -> INFO 1d3[0m Creating batch with 1 requests OUT - 20:47:56.548 [consensus/pbft] executeOne -> INFO 1d4[0m Replica 0 executing/committing request batch for view=0/seqNo=32 and digest HfK1r9YKy8VyEKJPyWbRITJalorskEzDb9xuxqsLvBQNWw1ePsH6W4NZtBHmm+Wgo5Q2TgumvLpApyPSvD5xWQ== OUT - 20:47:56.549 [consensus/pbft] execDoneSync -> INFO 1d5[0m Replica 0 finished execution 32, trying next
chaincode
/*
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
//WARNING - this chaincode's ID is hard-coded in chaincode_example04 to illustrate one way of
//calling chaincode from a chaincode. If this example is modified, chaincode_example04.go has
//to be modified as well with the new ID of chaincode_example02.
//chaincode_example05 show's how chaincode ID can be passed in as a parameter instead of
//hard-coding.
import (
"fmt"
"strconv"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
// SimpleChaincode example simple Chaincode implementation
type SimpleChaincode struct {
}
func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
fmt.Println("ex02 Init")
_, args := stub.GetFunctionAndParameters()
var A, B string // Entities
var Aval, Bval int // Asset holdings
var err error
if len(args) != 4 {
return shim.Error("Incorrect number of arguments. Expecting 4")
}
// Initialize the chaincode
A = args[0]
Aval, err = strconv.Atoi(args[1])
if err != nil {
return shim.Error("Expecting integer value for asset holding")
}
B = args[2]
Bval, err = strconv.Atoi(args[3])
if err != nil {
return shim.Error("Expecting integer value for asset holding")
}
fmt.Printf("Aval = %d, Bval = %d\n", Aval, Bval)
// Write the state to the ledger
err = stub.PutState(A, []byte(strconv.Itoa(Aval)))
if err != nil {
return shim.Error(err.Error())
}
err = stub.PutState(B, []byte(strconv.Itoa(Bval)))
if err != nil {
return shim.Error(err.Error())
}
return shim.Success(nil)
}
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
fmt.Println("ex02 Invoke")
function, args := stub.GetFunctionAndParameters()
if function == "invoke" {
// Make payment of X units from A to B
return t.invoke(stub, args)
} else if function == "delete" {
// Deletes an entity from its state
return t.delete(stub, args)
} else if function == "query" {
// the old "Query" is now implemtned in invoke
return t.query(stub, args)
}
return shim.Error("Invalid invoke function name. Expecting \"invoke\" \"delete\" \"query\"")
}
// Transaction makes payment of X units from A to B
func (t *SimpleChaincode) invoke(stub shim.ChaincodeStubInterface, args []string) pb.Response {
var A, B string // Entities
var Aval, Bval int // Asset holdings
var X int // Transaction value
var err error
if len(args) != 3 {
return shim.Error("Incorrect number of arguments. Expecting 3")
}
A = args[0]
B = args[1]
// Get the state from the ledger
// TODO: will be nice to have a GetAllState call to ledger
Avalbytes, err := stub.GetState(A)
if err != nil {
return shim.Error("Failed to get state")
}
if Avalbytes == nil {
return shim.Error("Entity not found")
}
Aval, _ = strconv.Atoi(string(Avalbytes))
Bvalbytes, err := stub.GetState(B)
if err != nil {
return shim.Error("Failed to get state")
}
if Bvalbytes == nil {
return shim.Error("Entity not found")
}
Bval, _ = strconv.Atoi(string(Bvalbytes))
// Perform the execution
X, err = strconv.Atoi(args[2])
if err != nil {
return shim.Error("Invalid transaction amount, expecting a integer value")
}
Aval = Aval - X
Bval = Bval + X
fmt.Printf("Aval = %d, Bval = %d\n", Aval, Bval)
// Write the state back to the ledger
err = stub.PutState(A, []byte(strconv.Itoa(Aval)))
if err != nil {
return shim.Error(err.Error())
}
err = stub.PutState(B, []byte(strconv.Itoa(Bval)))
if err != nil {
return shim.Error(err.Error())
}
return shim.Success(nil)
}
// Deletes an entity from state
func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string) pb.Response {
if len(args) != 1 {
return shim.Error("Incorrect number of arguments. Expecting 1")
}
A := args[0]
// Delete the key from the state in ledger
err := stub.DelState(A)
if err != nil {
return shim.Error("Failed to delete state")
}
return shim.Success(nil)
}
// query callback representing the query of a chaincode
func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) pb.Response {
var A string // Entities
var err error
if len(args) != 1 {
return shim.Error("Incorrect number of arguments. Expecting name of the person to query")
}
A = args[0]
// Get the state from the ledger
Avalbytes, err := stub.GetState(A)
if err != nil {
jsonResp := "{\"Error\":\"Failed to get state for " + A + "\"}"
return shim.Error(jsonResp)
}
if Avalbytes == nil {
jsonResp := "{\"Error\":\"Nil amount for " + A + "\"}"
return shim.Error(jsonResp)
}
jsonResp := "{\"Name\":\"" + A + "\",\"Amount\":\"" + string(Avalbytes) + "\"}"
fmt.Printf("Query Response:%s\n", jsonResp)
return shim.Success(Avalbytes)
}
func main() {
err := shim.Start(new(SimpleChaincode))
if err != nil {
fmt.Printf("Error starting Simple chaincode: %s", err)
}
}
Можете ли вы предоставить ссылку на пример chaincode_example02, чтобы мы знали, на что вы ссылаетесь? –