Skip to content

Commit

Permalink
FAB-5474 add links to godoc resources
Browse files Browse the repository at this point in the history
Change-Id: I13af4e7452cac28d0708ab4ba996af05f3fc8614
Signed-off-by: Christopher Ferris <chrisfer@us.ibm.com>
  • Loading branch information
christo4ferris committed Jul 26, 2017
1 parent e7b20bd commit 65730c8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
30 changes: 17 additions & 13 deletions docs/source/chaincode4ade.rst
Expand Up @@ -24,7 +24,7 @@ Chaincode API
-------------

Every chaincode program must implement the
`Chaincode interface <https://github.com/hyperledger/fabric/blob/master/core/chaincode/shim/interfaces.go#L28>`_
`Chaincode interface <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#Chaincode>`_
whose methods are called in response to received transactions.
In particular the ``Init`` method is called when a
chaincode receives an ``instantiate`` or ``upgrade`` transaction so that the
Expand All @@ -33,7 +33,7 @@ application state. The ``Invoke`` method is called in response to receiving an
``invoke`` transaction to process transaction proposals.

The other interface in the chaincode "shim" APIs is the
`ChaincodeStubInterface <https://github.com/hyperledger/fabric/blob/master/core/chaincode/shim/interfaces.go#L42>`_
`ChaincodeStubInterface <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeStub>`_
which is used to access and modify the ledger, and to make invocations between
chaincodes.

Expand Down Expand Up @@ -72,10 +72,11 @@ Housekeeping
^^^^^^^^^^^^

First, let's start with some housekeeping. As with every chaincode, it implements the
`Chaincode interface` <https://github.com/hyperledger/fabric/blob/master/core/chaincode/shim/interfaces.go#L28>_,
`Chaincode interface <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#Chaincode>`_
in particular, ``Init`` and ``Invoke`` functions. So, let's add the go import
statements for the necessary dependencies for our chaincode. We'll import the
chaincode shim package and the peer protobuf package.
chaincode shim package and the
`peer protobuf package <http://godoc.org/github.com/hyperledger/fabric/protos/peer>`_.

.. code:: go
Expand Down Expand Up @@ -106,8 +107,8 @@ Next, we'll implement the ``Init`` function.
no "migration" or nothing to be initialized as part of the upgrade.

Next, we'll retrieve the arguments to the ``Init`` call using the
``ChaincodeStubInterface.GetStringArgs`` function and check for validity.
In our case, we are expecting a key-value pair.
`ChaincodeStubInterface.GetStringArgs <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeStub.GetStringArgs>`_
function and check for validity. In our case, we are expecting a key-value pair.

.. code:: go
Expand All @@ -125,9 +126,9 @@ In our case, we are expecting a key-value pair.
Next, now that we have established that the call is valid, we'll store the
initial state in the ledger. To do this, we will call
``ChaincodeStubInterface.PutState`` with the key and value passed in as
the arguments. Assuming all went well, return a peer.Response object that
indicates the initialization was a success.
`ChaincodeStubInterface.PutState <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeStub.PutState>`_
with the key and value passed in as the arguments. Assuming all went well,
return a peer.Response object that indicates the initialization was a success.

.. code:: go
Expand Down Expand Up @@ -171,8 +172,9 @@ As with the ``Init`` function above, we need to extract the arguments from the
name of the chaincode application function to invoke. In our case, our application
will simply have two functions: ``set`` and ``get``, that allow the value of an
asset to be set or its current state to be retrieved. We first call
``ChaincodeStubInterface.GetFunctionAndParameters`` to extract the function
name and the parameters to that chaincode application function.
`ChaincodeStubInterface.GetFunctionAndParameters <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeStub.GetFunctionAndParameters>`_
to extract the function name and the parameters to that chaincode application
function.

.. code:: go
Expand Down Expand Up @@ -220,7 +222,8 @@ Implementing the Chaincode Application
As noted, our chaincode application implements two functions that can be
invoked via the ``Invoke`` function. Let's implement those functions now.
Note that as we mentioned above, to access the ledger's state, we will leverage
the ``ChaincodeStubInterface.PutState`` and ``ChaincodeStubInterface.GetState``
the `ChaincodeStubInterface.PutState <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeStub.PutState>`_
and `ChaincodeStubInterface.GetState <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeStub.GetState>`_
functions of the chaincode shim API.

.. code:: go
Expand Down Expand Up @@ -261,7 +264,8 @@ Pulling it All Together
^^^^^^^^^^^^^^^^^^^^^^^

Finally, we need to add the ``main`` function, which will call the
``shim.Start`` function. Here's the whole chaincode program source.
`shim.Start <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#Start>`_
function. Here's the whole chaincode program source.

.. code:: go
Expand Down
28 changes: 28 additions & 0 deletions docs/source/getting_started.rst
Expand Up @@ -11,6 +11,7 @@ Hyperledger Fabric.

Install Binaries and Docker Images
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

While we work on developing real installers for the Hyperledger Fabric
binaries, we provide a script that will :ref:`binaries` to your system.
The script also will download the Docker images to your local registry.
Expand All @@ -22,6 +23,33 @@ We offer a set of sample applications that you may wish to install these
:doc:`samples` before starting with the tutorials as the tutorials leverage
the sample code.

API Documentation
^^^^^^^^^^^^^^^^^

The API documentation for Hyperledger Fabric's Golang APIs can be found on
the godoc site for `Fabric <http://godoc.org/github.com/hyperledger/fabric>`_.
If you plan on doing any development using these APIs, you may want to
bookmark those links now.

Hyperledger Fabric SDKs
^^^^^^^^^^^^^^^^^^^^^^^

Hyperledger Fabric intends to offer a number of SDKs for a wide variety of
programming languages. The first two delivered SDKs are the Node.js and Java
SDKs. We hope to provide Python and Go SDKs soon after the 1.0.0 release.

* `Hyperledger Fabric Node SDK documentation <https://fabric-sdk-node.github.io/>`__.
* `Hyperledger Fabric Java SDK documentation <https://github.com/hyperledger/fabric-sdk-java>`__.

Hyperledger Fabric CA
^^^^^^^^^^^^^^^^^^^^^

Hyperledger Fabric provides an optional
`certificate authority service <http://hyperledger-fabric-ca.readthedocs.io/en/latest>`_
that you may choose to use to generate the certificates and key material
to configure and manage identity in your blockchain network. However, any CA
that can generate ECDSA certificates may be used.

Tutorials
^^^^^^^^^

Expand Down

0 comments on commit 65730c8

Please sign in to comment.