Skip to content

Instantly share code, notes, and snippets.

View mbwhite's full-sized avatar

Matthew B White mbwhite

View GitHub Profile
@mbwhite
mbwhite / JavaChaincodeQuickStart.md
Created October 14, 2019 10:59
Draft of QuickStart with Fabric Java Chaincode

Quick Start - Java Chaincode

Aim: to get up and working with Java Chaincode as quick as possible. Also as a sanity check that everything is setup correctly.

Assumptions

That you have:

  • git installed
  • docker and docker-compose installed
@mbwhite
mbwhite / gist:668494565bf0b155c6fb60627f9deb09
Created October 15, 2019 09:46
2.0 LIfecycle cheat sheet
## Cheat Sheet for sequence of commands for v2.0 lifecycle and byfn
docker kill $(docker ps -q) && docker rm $(docker ps -aq)
docker rmi $(docker images dev-* -q) --force
docker volume prune -f && docker network prune -f
./byfn.sh generate
./byfn.sh restart
# org1 ->
docker exec -it cli bash
@mbwhite
mbwhite / monitordocker.sh
Last active November 18, 2019 13:39
Live monitoring of docker containers
#!/bin/bash
# You can use this command to get this script
#
# curl -LOs https://gist.github.com/mbwhite/a32abc57a0a45ecc466977ceef67df1f/raw/monitordocker.sh && chmod +x monitordocker.sh
#
# This script uses the logspout and http stream tools to let you watch the docker containers
# in action.
#
# More information at https://github.com/gliderlabs/logspout/tree/master/httpstream
@mbwhite
mbwhite / Setup
Last active December 20, 2019 22:22
RPi Setup
https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
rsync -azvh ~/github.com $BACKUP/
https://www.raspberrypi.org/documentation/remote-access/ssh/README.md
https://www.raspberrypi.org/documentation/configuration/raspi-config.md
Change pwd
@mbwhite
mbwhite / getLatestDockerImages.sh
Created January 21, 2020 09:37
Gets the master branch Fabric Docker images
#!/bin/bash -e
set -euo pipefail
echo "======== PULL DOCKER IMAGES ========"
###############################################################
# Pull and Tag the fabric and fabric-ca images from Artifactory
###############################################################
echo "Fetching images from Artifactory"
ARTIFACTORY_URL=hyperledger-fabric.jfrog.io
@mbwhite
mbwhite / ansible_setup.sh
Last active January 29, 2020 16:43
Using Ansible Playbooks for Hyperledger Fabric v2
# Download Fabric CLI
wget -q -P /tmp https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-linux-amd64-latest.tar.gz
sudo tar xzvf /tmp/hyperledger-fabric-linux-amd64-latest.tar.gz -C /usr/local
# Download Fabric-ca CLI
wget -q -P /tmp https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-ca-linux-amd64-latest.tar.gz
sudo tar xzvf /tmp/hyperledger-fabric-ca-linux-amd64-latest.tar.gz -C /usr/local
export FABRIC_CFG_PATH=/usr/local/config
@mbwhite
mbwhite / endorsmentpolicy.pegjs
Created April 29, 2020 12:55
Hyperledger Fabric: Parsing the Endorsement Policies
// Grammar for parsing of the Fabric Endorsment Policies
//
// Defined in the documentation at
// https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#endorsement-policy-syntax
// The expression will be an operator with arguments, each of the arguments can be an expression
// The OutOf operator is a bit different as that demands the first agument be a number
Expression
= op:Operator '(' _ args:Some_Expression_Args _ ')'
{
@mbwhite
mbwhite / lifecycle.md
Last active June 25, 2020 09:51
Fabric Chaincode Lifecycle

Chaincode Package

The starting point of deploying a brand new chaincode starts with the chaincode package.

Irrespective of what language or api you have used to write your contract or chaincode, from the peer's perspective when deploying it can be considered a BLOB (Binary Object). Therefore the package is made up of your code (treated as a BLOB) and some metadata.

This metadata is a JSON file with

  • Code Path : for when the BLOG is unpacked where in the resulting directory tree the code is
  • Type : to indicate what type of builder is needed
@mbwhite
mbwhite / notes.md
Last active July 30, 2020 09:34
Building Node modules with native code with restricted/no internet connection

Scenario

No internet connection or limited. npm install will access npmjs to install node modules, any native modules will attempt to load the native modules that have been pre-built. This is defined the relavent package author's in each module's package.json.

However if there is no prebuilt binary available either because ones not defined, or the connection can not be established it will be rebuilt. This itself though will access the internet to get the node headers.

Steps to workaround this

0. Don't use native modules

If you can, but sometimes not practical or possible

@mbwhite
mbwhite / versions.js
Created January 19, 2021 11:30
Very simple query of IBP using the node sdk
// Apache-2
// Import and IBP Node SDK, and also two cli helpers
const ibp = require('ibp-node-sdk');
const { table } = require('table');
const chalk = require('chalk');
// package JSON contains
// "chalk": "^4.1.0",
// "ibp-node-sdk": "^0.1.11",