Skip to content

Commit

Permalink
update startup.sh all chapters, update sample.js all chapters;
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Dill committed Aug 29, 2018
1 parent 84a2a64 commit 585dd98
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 74 deletions.
12 changes: 6 additions & 6 deletions Chapter04/network/lib/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function CreateOrder(purchase) {
* @transaction
*/
function Buy(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Created))
if (purchase.order.status == JSON.stringify(orderStatus.Created))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -64,7 +64,7 @@ function Buy(purchase) {
* @transaction
*/
function OrderCancel(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.Created)) || (purchase.order.status = JSON.stringify(orderStatus.Bought)))
if ((purchase.order.status == JSON.stringify(orderStatus.Created)) || (purchase.order.status == JSON.stringify(orderStatus.Bought)))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -79,7 +79,7 @@ function OrderCancel(purchase) {
* @transaction
*/
function OrderFromSupplier(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Bought))
if (purchase.order.status == JSON.stringify(orderStatus.Bought))
{
purchase.order.provider = purchase.provider;
/*
Expand All @@ -93,7 +93,7 @@ function OrderFromSupplier(purchase) {
* @transaction
*/
function RequestShipping(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Ordered))
if (purchase.order.status == JSON.stringify(orderStatus.Ordered))
{
purchase.order.shipper = purchase.shipper;
/*
Expand All @@ -107,7 +107,7 @@ function RequestShipping(purchase) {
* @transaction
*/
function Delivering(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivering = new Date().toISOString();
var _status = orderStatus.Delivering;
Expand All @@ -123,7 +123,7 @@ function Delivering(purchase) {
* @transaction
*/
function Deliver(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
/*
** Your Code Goes Here
Expand Down
12 changes: 6 additions & 6 deletions Chapter05/network/lib/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function CreateOrder(purchase) {
* @transaction
*/
function Buy(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Created))
if (purchase.order.status == JSON.stringify(orderStatus.Created))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -70,7 +70,7 @@ function Buy(purchase) {
* @transaction
*/
function OrderCancel(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.Created)) || (purchase.order.status = JSON.stringify(orderStatus.Bought)))
if ((purchase.order.status == JSON.stringify(orderStatus.Created)) || (purchase.order.status == JSON.stringify(orderStatus.Bought)))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -88,7 +88,7 @@ function OrderCancel(purchase) {
* @transaction
*/
function OrderFromSupplier(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Bought))
if (purchase.order.status == JSON.stringify(orderStatus.Bought))
{
purchase.order.provider = purchase.provider;
purchase.order.ordered = new Date().toISOString();
Expand All @@ -105,7 +105,7 @@ function OrderFromSupplier(purchase) {
* @transaction
*/
function RequestShipping(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Ordered))
if (purchase.order.status == JSON.stringify(orderStatus.Ordered))
{
purchase.order.shipper = purchase.shipper;
purchase.order.requestShipment = new Date().toISOString();
Expand All @@ -122,7 +122,7 @@ function RequestShipping(purchase) {
* @transaction
*/
function Delivering(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivering = new Date().toISOString();
var _status = orderStatus.Delivering;
Expand All @@ -140,7 +140,7 @@ function Delivering(purchase) {
* @transaction
*/
function Deliver(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivered = new Date().toISOString();
purchase.order.status = JSON.stringify(orderStatus.Delivered);
Expand Down
12 changes: 6 additions & 6 deletions Chapter06/network/lib/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function CreateOrder(purchase) {
* @transaction
*/
function Buy(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Created))
if (purchase.order.status == JSON.stringify(orderStatus.Created))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -69,7 +69,7 @@ function Buy(purchase) {
* @transaction
*/
function OrderCancel(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.Created)) || (purchase.order.status = JSON.stringify(orderStatus.Bought)))
if ((purchase.order.status == JSON.stringify(orderStatus.Created)) || (purchase.order.status == JSON.stringify(orderStatus.Bought)))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -87,7 +87,7 @@ function OrderCancel(purchase) {
* @transaction
*/
function OrderFromSupplier(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Bought))
if (purchase.order.status == JSON.stringify(orderStatus.Bought))
{
purchase.order.provider = purchase.provider;
purchase.order.ordered = new Date().toISOString();
Expand All @@ -104,7 +104,7 @@ function OrderFromSupplier(purchase) {
* @transaction
*/
function RequestShipping(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Ordered))
if (purchase.order.status == JSON.stringify(orderStatus.Ordered))
{
purchase.order.shipper = purchase.shipper;
purchase.order.requestShipment = new Date().toISOString();
Expand All @@ -121,7 +121,7 @@ function RequestShipping(purchase) {
* @transaction
*/
function Delivering(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivering = new Date().toISOString();
var _status = orderStatus.Delivering;
Expand All @@ -139,7 +139,7 @@ function Delivering(purchase) {
* @transaction
*/
function Deliver(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivered = new Date().toISOString();
purchase.order.status = JSON.stringify(orderStatus.Delivered);
Expand Down
17 changes: 16 additions & 1 deletion Chapter06/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function getCurrent()
{
showStep "getting current directory"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "DIR in startup.sh is $DIR"
THIS_SCRIPT=`basename "$0"`
showStep "Running '${THIS_SCRIPT}'"
}
Expand All @@ -30,7 +31,8 @@ function showStep ()
echo -e "${RESET}-----> $*" | indent
echo -e "${YELLOW}=====================================================${RESET}" | indent
}

showStep "running getCurrent"
getCurrent
showStep "using execs from previous installation, stored in ${HLF_INSTALL_PATH}"
cd "${HLF_INSTALL_PATH}"
showStep "starting fabric"
Expand All @@ -42,5 +44,18 @@ showStep "starting fabric"
#
showStep "creating new PeerAdmin card (required with each restart)"
./createPeerAdminCard.sh
showStep "copying admin card to ~/.hfc-key-store"
CA_PEM_SOURCE="$DIR/controller/restapi/features/composer/creds"
PEER_SOURCE="$HOME/.composer/client-data/PeerAdmin@hlfv1/*"
HFC_KEY_STORE="$HOME/.hfc-key-store"
echo "CA_PEM_SOURCE is: $CA_PEM_SOURCE"
echo "PEER_SOURCE is: $PEER_SOURCE"
echo "HFC_KEY_STORE is: $HFC_KEY_STORE"
rm -R $HFC_KEY_STORE/
mkdir $HFC_KEY_STORE
cp -Rv ${CA_PEM_SOURCE}/ca.pem ${HFC_KEY_STORE}/
cp -Rv ${PEER_SOURCE} ${HFC_KEY_STORE}/
cp -Rv ${PEER_SOURCE} ${CA_PEM_SOURCE}/
showStep 'Listing current cards'
composer card list --name PeerAdmin@hlfv1
showStep "start up complete"
12 changes: 6 additions & 6 deletions Chapter07/network/lib/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function CreateOrder(purchase) {
* @transaction
*/
function Buy(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Created))
if (purchase.order.status == JSON.stringify(orderStatus.Created))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -69,7 +69,7 @@ function Buy(purchase) {
* @transaction
*/
function OrderCancel(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.Created)) || (purchase.order.status = JSON.stringify(orderStatus.Bought)))
if ((purchase.order.status == JSON.stringify(orderStatus.Created)) || (purchase.order.status == JSON.stringify(orderStatus.Bought)))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -87,7 +87,7 @@ function OrderCancel(purchase) {
* @transaction
*/
function OrderFromSupplier(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Bought))
if (purchase.order.status == JSON.stringify(orderStatus.Bought))
{
purchase.order.provider = purchase.provider;
purchase.order.ordered = new Date().toISOString();
Expand All @@ -104,7 +104,7 @@ function OrderFromSupplier(purchase) {
* @transaction
*/
function RequestShipping(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Ordered))
if (purchase.order.status == JSON.stringify(orderStatus.Ordered))
{
purchase.order.shipper = purchase.shipper;
purchase.order.requestShipment = new Date().toISOString();
Expand All @@ -121,7 +121,7 @@ function RequestShipping(purchase) {
* @transaction
*/
function Delivering(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivering = new Date().toISOString();
var _status = orderStatus.Delivering;
Expand All @@ -139,7 +139,7 @@ function Delivering(purchase) {
* @transaction
*/
function Deliver(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivered = new Date().toISOString();
purchase.order.status = JSON.stringify(orderStatus.Delivered);
Expand Down
17 changes: 16 additions & 1 deletion Chapter07/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function getCurrent()
{
showStep "getting current directory"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "DIR in startup.sh is $DIR"
THIS_SCRIPT=`basename "$0"`
showStep "Running '${THIS_SCRIPT}'"
}
Expand All @@ -30,7 +31,8 @@ function showStep ()
echo -e "${RESET}-----> $*" | indent
echo -e "${YELLOW}=====================================================${RESET}" | indent
}

showStep "running getCurrent"
getCurrent
showStep "using execs from previous installation, stored in ${HLF_INSTALL_PATH}"
cd "${HLF_INSTALL_PATH}"
showStep "starting fabric"
Expand All @@ -42,5 +44,18 @@ showStep "starting fabric"
#
showStep "creating new PeerAdmin card (required with each restart)"
./createPeerAdminCard.sh
showStep "copying admin card to ~/.hfc-key-store"
CA_PEM_SOURCE="$DIR/controller/restapi/features/composer/creds"
PEER_SOURCE="$HOME/.composer/client-data/PeerAdmin@hlfv1/*"
HFC_KEY_STORE="$HOME/.hfc-key-store"
echo "CA_PEM_SOURCE is: $CA_PEM_SOURCE"
echo "PEER_SOURCE is: $PEER_SOURCE"
echo "HFC_KEY_STORE is: $HFC_KEY_STORE"
rm -R $HFC_KEY_STORE/
mkdir $HFC_KEY_STORE
cp -Rv ${CA_PEM_SOURCE}/ca.pem ${HFC_KEY_STORE}/
cp -Rv ${PEER_SOURCE} ${HFC_KEY_STORE}/
cp -Rv ${PEER_SOURCE} ${CA_PEM_SOURCE}/
showStep 'Listing current cards'
composer card list --name PeerAdmin@hlfv1
showStep "start up complete"
12 changes: 6 additions & 6 deletions Chapter08/network/lib/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function CreateOrder(purchase) {
* @transaction
*/
function Buy(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Created))
if (purchase.order.status == JSON.stringify(orderStatus.Created))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -69,7 +69,7 @@ function Buy(purchase) {
* @transaction
*/
function OrderCancel(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.Created)) || (purchase.order.status = JSON.stringify(orderStatus.Bought)))
if ((purchase.order.status == JSON.stringify(orderStatus.Created)) || (purchase.order.status == JSON.stringify(orderStatus.Bought)) || (purchase.order.status == JSON.stringify(orderStatus.Backordered)))
{
purchase.order.buyer = purchase.buyer;
purchase.order.seller = purchase.seller;
Expand All @@ -87,7 +87,7 @@ function OrderCancel(purchase) {
* @transaction
*/
function OrderFromSupplier(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Bought))
if (purchase.order.status == JSON.stringify(orderStatus.Bought))
{
purchase.order.provider = purchase.provider;
purchase.order.ordered = new Date().toISOString();
Expand All @@ -104,7 +104,7 @@ function OrderFromSupplier(purchase) {
* @transaction
*/
function RequestShipping(purchase) {
if (purchase.order.status = JSON.stringify(orderStatus.Ordered))
if (purchase.order.status == JSON.stringify(orderStatus.Ordered))
{
purchase.order.shipper = purchase.shipper;
purchase.order.requestShipment = new Date().toISOString();
Expand All @@ -121,7 +121,7 @@ function RequestShipping(purchase) {
* @transaction
*/
function Delivering(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivering = new Date().toISOString();
var _status = orderStatus.Delivering;
Expand All @@ -139,7 +139,7 @@ function Delivering(purchase) {
* @transaction
*/
function Deliver(purchase) {
if ((purchase.order.status = JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code = orderStatus.Delivering.code))
if ((purchase.order.status == JSON.stringify(orderStatus.ShipRequest)) || (JSON.parse(purchase.order.status).code == orderStatus.Delivering.code))
{
purchase.order.delivered = new Date().toISOString();
purchase.order.status = JSON.stringify(orderStatus.Delivered);
Expand Down
17 changes: 16 additions & 1 deletion Chapter08/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function getCurrent()
{
showStep "getting current directory"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "DIR in startup.sh is $DIR"
THIS_SCRIPT=`basename "$0"`
showStep "Running '${THIS_SCRIPT}'"
}
Expand All @@ -30,7 +31,8 @@ function showStep ()
echo -e "${RESET}-----> $*" | indent
echo -e "${YELLOW}=====================================================${RESET}" | indent
}

showStep "running getCurrent"
getCurrent
showStep "using execs from previous installation, stored in ${HLF_INSTALL_PATH}"
cd "${HLF_INSTALL_PATH}"
showStep "starting fabric"
Expand All @@ -42,5 +44,18 @@ showStep "starting fabric"
#
showStep "creating new PeerAdmin card (required with each restart)"
./createPeerAdminCard.sh
showStep "copying admin card to ~/.hfc-key-store"
CA_PEM_SOURCE="$DIR/controller/restapi/features/composer/creds"
PEER_SOURCE="$HOME/.composer/client-data/PeerAdmin@hlfv1/*"
HFC_KEY_STORE="$HOME/.hfc-key-store"
echo "CA_PEM_SOURCE is: $CA_PEM_SOURCE"
echo "PEER_SOURCE is: $PEER_SOURCE"
echo "HFC_KEY_STORE is: $HFC_KEY_STORE"
rm -R $HFC_KEY_STORE/
mkdir $HFC_KEY_STORE
cp -Rv ${CA_PEM_SOURCE}/ca.pem ${HFC_KEY_STORE}/
cp -Rv ${PEER_SOURCE} ${HFC_KEY_STORE}/
cp -Rv ${PEER_SOURCE} ${CA_PEM_SOURCE}/
showStep 'Listing current cards'
composer card list --name PeerAdmin@hlfv1
showStep "start up complete"
Loading

0 comments on commit 585dd98

Please sign in to comment.