Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FABCN-391 Remove references to 2.0 and 2.0.0 #110

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,47 @@ Github is used for code base management, issues should reported in the [FABCN](h

## Summary of Compatibility

This table shows the summary of the compatibility of the Node modules at versions 1.4 and 2.0, together with the Nodejs runtime they require and the Fabric Peer versions they can communicate with.
This table shows the summary of the compatibility of the Node modules at versions 1.4 and 2.x, together with the Nodejs runtime they require and the Fabric Peer versions they can communicate with.

| | Peer Connectivity v1.4 | NodeJS | Peer Connectivity v2.0 |
| | Peer Connectivity v1.4 | NodeJS | Peer Connectivity v2.x |
| --------------------- | ---------------------- | ------ | ---------------------- |
| Node modules **v1.4** | Yes | 8 | Yes |
| Node modules **v2.0** | Yes | 10 | Yes |
| Node modules **v2.x** | Yes | 10 | Yes |

By default a Fabric Peer v1.4 will create a Nodejs v8 runtime, and a Fabric Peer v2.0 will create a Nodejs v10 runtime. Whilst is the default, the docker image used to host the chaincode and contracts can be altered. Set the environment variable `CORE_CHAINCODE_NODE_RUNTIME` on the peer to the name of the docker image. For example `CORE_CHAINCODE_NODE_RUNTIME=example/customNodeRuntime:latest`
By default a Fabric Peer v1.4 will create a Nodejs v8 runtime, and a Fabric Peer v2.x will create a Nodejs v10 runtime. Whilst this is the default, the docker image used to host the chaincode and contracts can be altered. Set the environment variable `CORE_CHAINCODE_NODE_RUNTIME` on the peer to the name of the docker image. For example `CORE_CHAINCODE_NODE_RUNTIME=example/customNodeRuntime:latest`

The Node modules will connect to the peer whilst running; this is referred to as 'Fabric Peer Connectivity' in the table. For example, whilst the Fabric Peer v1.4 will create a Nodejs 8 runtime, if a Nodejs 12 runtime was configured, the Node modules at v2.0.0 still function when connecting to the Fabric Peer v1.4.
The Node modules will connect to the peer whilst running; this is referred to as 'Fabric Peer Connectivity' in the table. For example, whilst the Fabric Peer v1.4 will create a Nodejs 8 runtime, if a Nodejs 12 runtime was configured, the node modules at v2.x still function when connecting to the Fabric Peer v1.4.

## Compatibility

The key elements are : 

- the version of the Fabric Contract Node modules used
- the version of the Nodejs runtime used to run the code
- When starting a chaincode container to run a Smart Contract the version of the runtime that is used is determined by these factors:
- When starting a chaincode container to run a Smart Contract, the version of the runtime that is used is determined by these factors:

Fabric v1.4.2, and Fabric v2.0.0 will, by default, start up docker image to host the chaincode and contracts. The version of the docker image used is defined by the version of Fabric in use.
Fabric v1.4.2, and Fabric v2.x will, by default, start up docker image to host the chaincode and contracts. The version of the docker image used is defined by the version of Fabric in use.

With Fabric v2.0.0, the chaincode container can be configured to be started by other means, and not the Peer. In this case, the environment used is not in the control of Fabric.
With Fabric v2.x, the chaincode container can be configured to be started by other means, and not the Peer. In this case, the environment used is not in the control of Fabric.

Node modules that are produced are `fabric-contract-api`, `fabric-shim`, `fabric-shim-crypto` & `fabric-shim-api`

### Supported Runtimes

v2.0.0 Node modules are supported running in Nodejs 10.15+, with the x86_64 architecture.
v2.x Node modules are supported running in Nodejs 10.15+, with the x86_64 architecture.

v1.4.x Node modules are supported running Nodejs 8.16.1 with the x86_64 architecture.

Architecture Support: all docker images, runtimes, tools are tested under x86_64 ONLY

### Default Peer Runtime selection

When using Fabric 2.0.0, the default docker image that is used to run the Node chaincode is node:10.15.2-alpine 
When using Fabric 2.x, the default docker image that is used to run the Node chaincode is node:10.15.2-alpine 

*Note:* With the default docker image used by Fabric 2.0.0 the packaged code will be installed with npm. If a `package-lock.json` or a `npm-shrinkwrap.json` file is present, `npm ci --only=production` will be used. Otherwise `npm install --production` will be used. 
*Note:* With the default docker image used by Fabric 2.x, the packaged code will be installed with npm. If a `package-lock.json` or a `npm-shrinkwrap.json` file is present, `npm ci --only=production` will be used. Otherwise `npm install --production` will be used. 

When using Fabric 1.4.4, the docker image that is used to run the Node chaincode is node v8.16.1. It is installed with npm install --production

### Supported Runtime communication with the Peer

Subject to a suitable runtime environment, the 1.4.4 Node modules and 2.0.0 Node modules can used to communicate with a Fabric 2.0.0 or 1.4.4 Peer - with the level of functionality that is implied by the Fabric version in use. 
Subject to a suitable runtime environment, the 1.4.4 Node modules and 2.x Node modules can be used to communicate with a Fabric 2.x or 1.4.4 Peer - with the level of functionality that is implied by the Fabric version in use. 
8 changes: 4 additions & 4 deletions docs/_jsdoc/tutorials/using-iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ An example of these apis (but may not be a complete list) is given here
- getStateByRange
- getStateByRangeWithPagination

These api's are a request to return a set of data for which you need to iterate over using the provided iterator. Some of these apis will return the iterator directly and others return an iterator as part of an object property. In previous versions of the fabric-shim api you would need to know which ones did that and handle it appropriately and you need to check the documentation, but the rules are
These apis are a request to return a set of data for which you need to iterate over using the provided iterator. Some of these apis will return the iterator directly and others return an iterator as part of an object property. In previous versions of the fabric-shim api you would need to know which ones did that and handle it appropriately and you need to check the documentation, but the rules are
- all private data range queries return an object with just an iterator property containing the iterator
- all Pagination queries return an object with an iterator property and metadata property
- all other rich/range/history queries return just the iterator itself.

These iterators were essentially asynchronous iterators (the next and close methods returned promises) but you couldn't use standard iterator capabilities such as for/of constructs in node because node could not work with the concept of asynchronous iterators.

From fabric v2.0 onwards, node chaincode will be using node 10 as the node version and this has added support for asynchronous iterators. Also in fabric v2.0 onwards fabric-shim has added support to enable it's asynchronous iterators so that `for/of` can now be used, but note that they don't have full support so should not be used in generator functions.
From fabric v2.x onwards, node chaincode will be using node 10 and this has added support for asynchronous iterators. Also in fabric v2.x onwards, fabric-shim has added support to enable it's asynchronous iterators so that `for/of` can now be used, but note that they don't have full support, so should not be used in generator functions.

As a comparison lets present first how you would use iterators in previous releases and then show the new way.
As a comparison, let's present first how you would use iterators in previous releases and then show the new way.

## How to use, the old way
In the past, you might have coded something like this to process an iterator
In the past, you might have coded something like this to process an iterator:

```javascript
async function getAllResults(iterator) {
Expand Down