// query
// Every readonly functions in the ledger will be here

query
Every readonly functions in the ledger will be here
// query // Every readonly functions in the ledger will be here
func (t *HeroesServiceChaincode) query(stub shim.ChaincodeStubInterface, args []string) pb.Response {
	fmt.Println("########### HeroesServiceChaincode query ###########")
	if len(args) < 2 {
		return shim.Error("The number of arguments is insufficient.")
	}
	state, err := stub.GetState(args[1])
	if err != nil {
		return shim.Error("Failed to get state of hello")
	}
	return shim.Success(state)
}
func ( t * HeroesServiceChaincode ) query ( stub shim . ChaincodeStubInterface , args [ ] string ) pb . Response { fmt . Println ( " " ) if len ( args ) < 2 { return shim . Error ( " " ) } state , err := stub . GetState ( args [ 1 ] ) if err != nil { return shim . Error ( " " ) } return shim . Success ( state ) }
query
Every readonly functions in the ledger will be here
query Every readonly functions in the ledger will be here
// Check whether the number of arguments is sufficient
 // Get the state of the value matching the key hello in the ledger
 /*
	resultsIterator, err := stub.GetQueryResult(args[1])
	if err != nil {
		return shim.Error("Failed to get state of chaincode")
	}
	defer resultsIterator.Close()

	// buffer is a JSON array containing QueryRecords
	var buffer bytes.Buffer
	buffer.WriteString("[")

	bArrayMemberAlreadyWritten := false
	for resultsIterator.HasNext() {
		queryResponse, err := resultsIterator.Next()
		if err != nil {
			return shim.Error("Failed to get state of chaincode")
		}
		// Add a comma before array members, suppress it for the first array member
		if bArrayMemberAlreadyWritten == true {
			buffer.WriteString(",")
		}
		buffer.WriteString("{\"Key\":")
		buffer.WriteString("\"")
		buffer.WriteString(queryResponse.Key)
		buffer.WriteString("\"")

		buffer.WriteString(", \"Record\":")
		// Record is a JSON object, so we write as-is
		buffer.WriteString(string(queryResponse.Value))
		buffer.WriteString("}")
		bArrayMemberAlreadyWritten = true
	}
	buffer.WriteString("]")

	fmt.Printf("- getQueryResultForQueryString queryResult:\n%s\n", buffer.String())

	return shim.Success(buffer.Bytes())
	*/ //return buffer.Bytes(), nil
