mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-19 00:15:08 +00:00
[FAB-13862] Rename example02 ABstore
Updated chaincode, BYFN, and all other references to example02 to use the new name ABstore. Change-Id: I04c177f9de68eb913f4384fd643aa69631143d58 Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
This commit is contained in:
parent
c7438e1f7c
commit
6007c0974c
17 changed files with 66 additions and 56 deletions
4
chaincode-docker-devmode/.gitignore
vendored
4
chaincode-docker-devmode/.gitignore
vendored
|
|
@ -1,3 +1,3 @@
|
|||
/myc.block
|
||||
/chaincode/sacc/sacc
|
||||
/chaincode/chaincode_example02/chaincode_example02
|
||||
/chaincode/sacc/go/sacc
|
||||
/chaincode/abstore/go/abstore
|
||||
|
|
|
|||
|
|
@ -86,14 +86,14 @@ Now, compile your chaincode:
|
|||
|
||||
.. code:: bash
|
||||
|
||||
cd chaincode_example02/go
|
||||
go build -o chaincode_example02
|
||||
cd abstore/go
|
||||
go build -o abstore
|
||||
|
||||
Now run the chaincode:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./chaincode_example02
|
||||
CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./abstore
|
||||
|
||||
The chaincode is started with peer and chaincode logs indicating successful registration with the peer.
|
||||
Note that at this stage the chaincode is not associated with any channel. This is done in subsequent steps
|
||||
|
|
@ -114,7 +114,7 @@ We'll leverage the CLI container to drive these calls.
|
|||
|
||||
.. code:: bash
|
||||
|
||||
peer chaincode install -p chaincodedev/chaincode/chaincode_example02/go -n mycc -v 0
|
||||
peer chaincode install -p chaincodedev/chaincode/abstore/go -n mycc -v 0
|
||||
peer chaincode instantiate -n mycc -v 0 -c '{"Args":["init","a","100","b","200"]}' -C myc
|
||||
|
||||
Now issue an invoke to move ``10`` from ``a`` to ``b``.
|
||||
|
|
@ -132,7 +132,7 @@ Finally, query ``a``. We should see a value of ``90``.
|
|||
Testing new chaincode
|
||||
---------------------
|
||||
|
||||
By default, we mount only ``chaincode_example02``. However, you can easily test different
|
||||
By default, we mount only ``abstore``. However, you can easily test different
|
||||
chaincodes by adding them to the ``chaincode`` subdirectory and relaunching
|
||||
your network. At this point they will be accessible in your ``chaincode`` container.
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ services:
|
|||
- GOPATH=/opt/gopath
|
||||
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
|
||||
- FABRIC_LOGGING_SPEC=DEBUG
|
||||
- CORE_PEER_ID=example02
|
||||
- CORE_PEER_ID=abstore
|
||||
- CORE_PEER_ADDRESS=peer:7051
|
||||
- CORE_PEER_LOCALMSPID=DEFAULT
|
||||
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp
|
||||
|
|
|
|||
|
|
@ -16,12 +16,6 @@ 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"
|
||||
|
|
@ -30,12 +24,12 @@ import (
|
|||
pb "github.com/hyperledger/fabric/protos/peer"
|
||||
)
|
||||
|
||||
// SimpleChaincode example simple Chaincode implementation
|
||||
type SimpleChaincode struct {
|
||||
// ABstore Chaincode implementation
|
||||
type ABstore struct {
|
||||
}
|
||||
|
||||
func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
|
||||
fmt.Println("ex02 Init")
|
||||
func (t *ABstore) Init(stub shim.ChaincodeStubInterface) pb.Response {
|
||||
fmt.Println("ABstore Init")
|
||||
_, args := stub.GetFunctionAndParameters()
|
||||
var A, B string // Entities
|
||||
var Aval, Bval int // Asset holdings
|
||||
|
|
@ -72,8 +66,8 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
|
|||
return shim.Success(nil)
|
||||
}
|
||||
|
||||
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
|
||||
fmt.Println("ex02 Invoke")
|
||||
func (t *ABstore) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
|
||||
fmt.Println("ABstore Invoke")
|
||||
function, args := stub.GetFunctionAndParameters()
|
||||
if function == "invoke" {
|
||||
// Make payment of X units from A to B
|
||||
|
|
@ -90,7 +84,7 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
|
|||
}
|
||||
|
||||
// Transaction makes payment of X units from A to B
|
||||
func (t *SimpleChaincode) invoke(stub shim.ChaincodeStubInterface, args []string) pb.Response {
|
||||
func (t *ABstore) invoke(stub shim.ChaincodeStubInterface, args []string) pb.Response {
|
||||
var A, B string // Entities
|
||||
var Aval, Bval int // Asset holdings
|
||||
var X int // Transaction value
|
||||
|
|
@ -147,7 +141,7 @@ func (t *SimpleChaincode) invoke(stub shim.ChaincodeStubInterface, args []string
|
|||
}
|
||||
|
||||
// Deletes an entity from state
|
||||
func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string) pb.Response {
|
||||
func (t *ABstore) delete(stub shim.ChaincodeStubInterface, args []string) pb.Response {
|
||||
if len(args) != 1 {
|
||||
return shim.Error("Incorrect number of arguments. Expecting 1")
|
||||
}
|
||||
|
|
@ -164,7 +158,7 @@ func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string
|
|||
}
|
||||
|
||||
// query callback representing the query of a chaincode
|
||||
func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) pb.Response {
|
||||
func (t *ABstore) query(stub shim.ChaincodeStubInterface, args []string) pb.Response {
|
||||
var A string // Entities
|
||||
var err error
|
||||
|
||||
|
|
@ -192,8 +186,8 @@ func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string)
|
|||
}
|
||||
|
||||
func main() {
|
||||
err := shim.Start(new(SimpleChaincode))
|
||||
err := shim.Start(new(ABstore))
|
||||
if err != nil {
|
||||
fmt.Printf("Error starting Simple chaincode: %s", err)
|
||||
fmt.Printf("Error starting ABstore chaincode: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,6 @@ shadowJar {
|
|||
classifier = null
|
||||
|
||||
manifest {
|
||||
attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleChaincode'
|
||||
attributes 'Main-Class': 'org.hyperledger.fabric_samples.ABstore'
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ Copyright IBM Corp., DTCC All Rights Reserved.
|
|||
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
package org.hyperledger.fabric.example;
|
||||
package org.hyperledger.fabric_samples;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -16,9 +16,9 @@ import org.hyperledger.fabric.shim.ChaincodeStub;
|
|||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
public class SimpleChaincode extends ChaincodeBase {
|
||||
public class ABstore extends ChaincodeBase {
|
||||
|
||||
private static Log _logger = LogFactory.getLog(SimpleChaincode.class);
|
||||
private static Log _logger = LogFactory.getLog(ABstore.class);
|
||||
|
||||
@Override
|
||||
public Response init(ChaincodeStub stub) {
|
||||
|
|
@ -136,7 +136,7 @@ public class SimpleChaincode extends ChaincodeBase {
|
|||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("OpenSSL avaliable: " + OpenSsl.isAvailable());
|
||||
new SimpleChaincode().start(args);
|
||||
new ABstore().start(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,11 +7,11 @@
|
|||
const shim = require('fabric-shim');
|
||||
const util = require('util');
|
||||
|
||||
var Chaincode = class {
|
||||
var ABstore = class {
|
||||
|
||||
// Initialize the chaincode
|
||||
async Init(stub) {
|
||||
console.info('========= example02 Init =========');
|
||||
console.info('========= ABstore Init =========');
|
||||
let ret = stub.getFunctionAndParameters();
|
||||
console.info(ret);
|
||||
let args = ret.params;
|
||||
|
|
@ -135,4 +135,4 @@ var Chaincode = class {
|
|||
}
|
||||
};
|
||||
|
||||
shim.start(new Chaincode());
|
||||
shim.start(new ABstore());
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
{
|
||||
"name": "chaincode_example02",
|
||||
"name": "abstore",
|
||||
"version": "1.0.0",
|
||||
"description": "chaincode_example02 chaincode implemented in node.js",
|
||||
"description": "ABstore chaincode implemented in node.js",
|
||||
"engines": {
|
||||
"node": ">=8.4.0",
|
||||
"npm": ">=5.3.0"
|
||||
},
|
||||
"scripts": { "start" : "node chaincode_example02.js" },
|
||||
"scripts": {
|
||||
"start": "node abstore.js"
|
||||
},
|
||||
"engine-strict": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
|
|
@ -100,7 +100,7 @@ channels:
|
|||
# this list with the query results of getInstalledChaincodes() and getInstantiatedChaincodes()
|
||||
chaincodes:
|
||||
# the format follows the "cannonical name" of chaincodes by fabric code
|
||||
- example02:v1
|
||||
- abstore:v1
|
||||
- marbles:1.0
|
||||
|
||||
#
|
||||
|
|
@ -222,4 +222,4 @@ certificateAuthorities:
|
|||
- enrollId: admin
|
||||
enrollSecret: adminpw
|
||||
# [Optional] The optional name of the CA.
|
||||
caName: ca-digibank
|
||||
caName: ca-digibank
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ channels:
|
|||
# this list with the query results of getInstalledChaincodes() and getInstantiatedChaincodes()
|
||||
chaincodes:
|
||||
# the format follows the "cannonical name" of chaincodes by fabric code
|
||||
- example02:v1
|
||||
- abstore:v1
|
||||
- marbles:1.0
|
||||
|
||||
#
|
||||
|
|
@ -222,4 +222,4 @@ certificateAuthorities:
|
|||
- enrollId: admin
|
||||
enrollSecret: adminpw
|
||||
# [Optional] The optional name of the CA.
|
||||
caName: ca-digibank
|
||||
caName: ca-digibank
|
||||
|
|
|
|||
|
|
@ -23,13 +23,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
|
|||
COUNTER=1
|
||||
MAX_RETRY=10
|
||||
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/"
|
||||
if [ "$LANGUAGE" = "node" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/"
|
||||
fi
|
||||
|
||||
if [ "$LANGUAGE" = "java" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/java/"
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/"
|
||||
elif [ "$LANGUAGE" = "java" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/"
|
||||
else
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/"
|
||||
fi
|
||||
|
||||
echo "Channel name : "$CHANNEL_NAME
|
||||
|
|
|
|||
|
|
@ -25,9 +25,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
|
|||
COUNTER=1
|
||||
MAX_RETRY=5
|
||||
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/"
|
||||
if [ "$LANGUAGE" = "node" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/"
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/"
|
||||
elif [ "$LANGUAGE" = "java" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/"
|
||||
else
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/"
|
||||
fi
|
||||
|
||||
# import utils
|
||||
|
|
|
|||
|
|
@ -28,9 +28,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
|
|||
COUNTER=1
|
||||
MAX_RETRY=5
|
||||
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/"
|
||||
if [ "$LANGUAGE" = "node" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/"
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/"
|
||||
elif [ "$LANGUAGE" = "java" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/"
|
||||
else
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/"
|
||||
fi
|
||||
|
||||
# import utils
|
||||
|
|
|
|||
|
|
@ -29,9 +29,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
|
|||
COUNTER=1
|
||||
MAX_RETRY=5
|
||||
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/"
|
||||
if [ "$LANGUAGE" = "node" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/"
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/"
|
||||
elif [ "$LANGUAGE" = "java" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/"
|
||||
else
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/"
|
||||
fi
|
||||
|
||||
# import utils
|
||||
|
|
|
|||
|
|
@ -33,9 +33,12 @@ LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
|
|||
COUNTER=1
|
||||
MAX_RETRY=5
|
||||
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/"
|
||||
if [ "$LANGUAGE" = "node" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/"
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/"
|
||||
elif [ "$LANGUAGE" = "java" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/"
|
||||
else
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/"
|
||||
fi
|
||||
|
||||
echo "Channel name : "$CHANNEL_NAME
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@ LANGUAGE=$(echo "$LANGUAGE" | tr [:upper:] [:lower:])
|
|||
COUNTER=1
|
||||
MAX_RETRY=5
|
||||
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/"
|
||||
if [ "$LANGUAGE" = "node" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/"
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/node/"
|
||||
elif [ "$LANGUAGE" = "java" ]; then
|
||||
CC_SRC_PATH="/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/"
|
||||
else
|
||||
CC_SRC_PATH="github.com/hyperledger/fabric-samples/chaincode/abstore/go/"
|
||||
fi
|
||||
|
||||
echo "Channel name : "$CHANNEL_NAME
|
||||
|
|
|
|||
Loading…
Reference in a new issue