Skip to content

Commit

Permalink
[FAB-13862] Rename example02 ABstore
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lehors committed Jan 30, 2019
1 parent c7438e1 commit 6007c09
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 56 deletions.
4 changes: 2 additions & 2 deletions chaincode-docker-devmode/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/myc.block
/chaincode/sacc/sacc
/chaincode/chaincode_example02/chaincode_example02
/chaincode/sacc/go/sacc
/chaincode/abstore/go/abstore
10 changes: 5 additions & 5 deletions chaincode-docker-devmode/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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``.
Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion chaincode-docker-devmode/docker-compose-simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")
}
Expand All @@ -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

Expand Down Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ shadowJar {
classifier = null

manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.example.SimpleChaincode'
attributes 'Main-Class': 'org.hyperledger.fabric_samples.ABstore'
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.example;
package org.hyperledger.fabric_samples;

import java.util.List;

Expand All @@ -16,9 +16,9 @@

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) {
Expand Down Expand Up @@ -136,7 +136,7 @@ private Response query(ChaincodeStub stub, List<String> args) {

public static void main(String[] args) {
System.out.println("OpenSSL avaliable: " + OpenSsl.isAvailable());
new SimpleChaincode().start(args);
new ABstore().start(args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -135,4 +135,4 @@ var Chaincode = class {
}
};

shim.start(new Chaincode());
shim.start(new ABstore());
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down Expand Up @@ -222,4 +222,4 @@ certificateAuthorities:
- enrollId: admin
enrollSecret: adminpw
# [Optional] The optional name of the CA.
caName: ca-digibank
caName: ca-digibank
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down Expand Up @@ -222,4 +222,4 @@ certificateAuthorities:
- enrollId: admin
enrollSecret: adminpw
# [Optional] The optional name of the CA.
caName: ca-digibank
caName: ca-digibank
11 changes: 5 additions & 6 deletions first-network/scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions first-network/scripts/step1org3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions first-network/scripts/step2org3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions first-network/scripts/step3org3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions first-network/scripts/testorg3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions first-network/scripts/upgrade_to_v14.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6007c09

Please sign in to comment.