Skip to content

Commit

Permalink
cleanup v0.6 release page
Browse files Browse the repository at this point in the history
fixed formatting and code snippets
[ci skip]

Change-Id: Ic4783ac4c70a64f404fc69076514735c329260bd
Signed-off-by: Nick Gaski <ngaski@us.ibm.com>
  • Loading branch information
nickgaski committed Nov 7, 2016
1 parent b50db2b commit ee5b85c
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions docs/v0.6_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ v0.6.1-preview release, and outlines the changes you will need to make to
successfully migrate code originally written for the v0.5-developer-preview
release that you now wish to run on fabric v0.6.1-preview.

# Migrating chaincode to fabric v0.6.1-preview
## Migrating chaincode to fabric v0.6.1-preview

* The chaincode shim interface changes for compatibility with the latest
__1.__ The chaincode shim interface changes for compatibility with the latest
Hyperledger shim:

The chaincode interface has changed from `shim.ChaincodeStub` to
Expand All @@ -16,13 +16,14 @@ highlight this alteration.

This change applies to all transaction types: Deploy, Invoke, and Query.

```go
```go

func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStub, function string, args []string) ([]byte, error) {

func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {
```
* Chaincode calling chaincode is included in the shim package.
__2.__ Chaincode calling chaincode is included in the shim package.
There are two functions available - **InvokeChaincode** and **QueryChaincode**.
First, these functions no longer accept the function name as a parameter;
Expand All @@ -32,19 +33,19 @@ your strings to a byte array.
The following code snippets from chaincode_example04 demonstrate the difference.
Make note of `f`, representing the function invoke. It is removed from the
InvokeChaincode parameters, and instead passed as an argument to the invokeArgs
**InvokeChaincode** parameters, and instead passed as an argument to the **invokeArgs**
element. The arguments are then converted to a byte array before being passed
to InvokeChaincode. This change is not optional and must be implemented in
to **InvokeChaincode**. This change is not optional and must be implemented in
your code.
```go
```go
// fabric v0.5-developer-preview
f := "invoke"
invokeArgs := []string{"a", "b", "10"}
response, err := stub.InvokeChaincode(chainCodeToCall, f, invokeArgs)
```
```go
```go
// fabric v0.6.1-preview code
f := "invoke"
// function is removed from InvokeChaincode, now passed as an argument within
Expand All @@ -53,7 +54,7 @@ invokeArgs := util.ToChaincodeArgs(f, "a", "b", "10")
response, err := stub.InvokeChaincode(chainCodeToCall, invokeArgs)
```
* Chaincode APIs have changed when constructing REST API payloads and CLI
__3.__ Chaincode APIs have changed when constructing REST API payloads and CLI
commands.
The function can now be passed within the "args" element as the
Expand Down Expand Up @@ -105,9 +106,9 @@ peer chaincode invoke -1 golang -n mycc -c '{"Args": ["invoke", "a", "b", "10"]}
with fabric v0.6.1-preview. However, when using the Java SDK you must implement
the new format, where the function is passed within the "args" element.
# New Features
## New Features
1. Custom Events & Event handler:
__1.__ Custom Events & Event handler:
The fabric now has the ability to create custom events and emit this information
to a client-side node application leveraging the hfc SDK. This is done by
Expand All @@ -119,7 +120,7 @@ sent. In the example, only the invoke transaction type is coded to send outgoing
events. See the following code snippet in eventsender.go which demonstrates
invocations being broadcast by the event sender:
```go
```go
func (t *EventSender) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {
b, err := stub.GetState("noevents")
if err != nil {
Expand Down Expand Up @@ -148,7 +149,7 @@ func (t *EventSender) Invoke(stub shim.ChaincodeStubInterface, function string,
Enable the event service in your node program with the following steps:
```go
```go
// set the port where the event service will listen
chain.eventHubConnect("localhost:7053");

Expand All @@ -174,35 +175,32 @@ process.on('exit', function() {
Explore the full library of the [sample event application](https://github.com/ratnakar-asara/NodeSDKSample/tree/master/events)
for the application source code and deeper documentation.
1. Java chaincode shim - new shim library to support java chaincode interacting
__2.__ Java chaincode shim - new shim library to support java chaincode interacting
with Hyperledger fabric. See the [java shim](fabric/core/chaincode/shim/java)
library for the source code.
1. Ability to call chaincode using a 64encoded string. A custom UnmarshalJSON
__3.__ Ability to call chaincode using a 64encoded string. A custom UnmarshalJSON
method for ChaincodeInput allows for string-based REST/JSON input, which is then
converted to []byte-based. This allows browsers to pass in string or binary
arguments to the application driving the chaincode.
1. Docker client upgrade to [Docker 1.12](https://blog.docker.com/2016/07/docker-built-in-orchestration-ready-for-production-docker-1-12-goes-ga/).
__4.__ Docker client upgrade to [Docker 1.12](https://blog.docker.com/2016/07/docker-built-in-orchestration-ready-for-production-docker-1-12-goes-ga/)
1. Peer and Member Service images available on [Hyperledger Dockerhub](https://hub.docker.com/r/hyperledger/). The images are part of the
continuous integration process and built with every new code change.
__5.__ `fabric-peer` and `fabric-membersrvc` images for multiple platforms are available on [Hyperledger Dockerhub](https://hub.docker.com/r/hyperledger/). The images are part of the continuous integration process and built with every new code change.
1. New warnings for chaincode development. The following practices can lead to
__6.__ New warnings for chaincode development. The following practices can lead to
malfunctioning and/or non-deterministic chaincode and should be avoided:
* Iterating using GetRows
* Using associative arrays with iteration (the order is randomized in Go)
* Reading list of items from KVS table (the order is not guaranteed). Use ordering
* Writing thread-unsafe chaincode where invoke and query may be called in parallel
* Substituting global memory or cache storage for ledger state variables in the chaincode
* Accessing external services (e.g. databases) directly from the chaincode
* Using libraries or globabl variables that could introduce non-determinism (e.g. "random" or "time")
1. For templates of deterministic and properly-written chaincode, see the [examples](fabric/examples/chaincode) library. This directory contains samples
written in Go and Java.
- Iterating using GetRows
- Using associative arrays with iteration (the order is randomized in Go)
- Reading list of items from KVS table (the order is not guaranteed). Use ordering
- Writing thread-unsafe chaincode where invoke and query may be called in parallel
- Substituting global memory or cache storage for ledger state variables in the chaincode
- Accessing external services (e.g. databases) directly from the chaincode
- Using libraries or globabl variables that could introduce non-determinism (e.g. "random" or "time")
- For templates of deterministic and properly-written chaincode, see the [examples](fabric/examples/chaincode) library. This directory contains samples written in Go and Java.
1. Fabric Starter Kit - This section describes how to set up a self-contained
__7.__ Fabric Starter Kit - This section describes how to set up a self-contained
environment for application development with the Hyperledger fabric. The setup
uses **Docker** to provide a controlled environment with all the necessary
Hyperledger fabric components to support a Node.js application built with
Expand All @@ -213,13 +211,13 @@ network environment. There is an image to run a single `peer`, one to run
the `membersrvc`, and one to run both your Node.js application and your
chaincode.
1. [Fabric boilerplate](https://github.com/IBM-Blockchain/fabric-boilerplate) -
__8.__ [Fabric boilerplate](https://github.com/IBM-Blockchain/fabric-boilerplate) -
The public IBM-Blockchain repo now contains a boilerplate application to help
application developers quickly create a network and deploy and app. The network
can be spun up locally using Docker containers or through a Bluemix instance of
the blockchain service.
1. Fabric v0.6 provides the ability to dynamically register and enroll users
__9.__ Fabric v0.6 provides the ability to dynamically register and enroll users
with attributes through the hfc SDK.
See [asset-mgmt-with-dynamic-roles.js](fabric/sdk/node/test/unit/asset-mgmt-with-dynamic-roles.js)
as an example. The hfc SDK previously allowed you to dynamically enroll users,
Expand Down

1 comment on commit ee5b85c

@Maheshbiradar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.\chaincode_finished.go:31: cannot use new(SimpleChaincode) (type *SimpleChainco
de) as type shim.Chaincode in argument to shim.Start:
*SimpleChaincode does not implement shim.Chaincode (wrong type for Init
method)
have Init(shim.ChaincodeStubInterface, string, []string) ([]byte
, error)
want Init(shim.ChaincodeStubInterface) ([]byte, error)

getting error..Please help

Please sign in to comment.