You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This updates the main RTD doc, as well as the accompanying low
level explanation. Dependent on 15049; DO NOT MERGE independently.
They must be added together; Fix merge conflict
Incorporate Dave, Bret, JZ & Gari feedback.
Update code snippets to mirror our javascript programs
Update doc to reflect new key store location
Update CouchDB references with capitalization
[ci-skip]
Change-Id: I43afad0ae946c7277f35e9ed5627097ec0c5ae2a
Signed-off-by: Nick Gaski <[email protected]>
Signed-off-by: Gari Singh <[email protected]>
(cherry picked from commit ad9fc9c)
Copy file name to clipboardexpand all lines: docs/source/understand_fabcar_network.rst
+38-46
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,8 @@ Obscuring the underpinnings of the network to that degree is fine for the
10
10
majority of application developers. They don't necessarily need to know how
11
11
network components actually work in detail in order to create their app.
12
12
13
-
But for those who do want to know about the fun stuff going on under the covers
14
-
(so to speak), let's go through how applications **connect** to the network and
13
+
But for those who do want to know about the fun stuff going on under the covers,
14
+
let's go through how applications **connect** to the network and
15
15
how they propose **queries** and **updates** on a more granular level, as well
16
16
as point out the differences between a small scale test network like Fabcar and
17
17
how apps will usually end up working in the real world.
@@ -23,18 +23,18 @@ role an application plays.
23
23
Components of the Fabcar Network
24
24
--------------------------------
25
25
26
-
The Fabcar network consists of one peer node, one ordering node (aka, the
27
-
"orderer"), a couchDB container, and a CLI container. This represents a
28
-
very limited network, without a certificate authority or any other
29
-
peers.
26
+
Fabcar uses the "basic-network" sample as its limited development network. It
27
+
consists of a single peer node configured to use CouchDB as the state database,
28
+
a single "solo" ordering node, a certificate authority (CA) and a CLI container
29
+
for executing commands.
30
30
31
31
For detailed information on these components and what they do, refer to
32
32
:doc:`build_network`.
33
33
34
34
These components are bootstrapped by the ``./startFabric.sh`` script, which
35
35
also:
36
36
* creates a channel and joins the peer to the channel
37
-
* installs smart contract onto the peer's file system and instantiates it on the channel (instantiate starts a container)
37
+
* installs the ``fabcar`` smart contract onto the peer's file system and instantiates it on the channel (instantiate starts a container)
38
38
* calls the ``initLedger`` function to populate the channel ledger with 10 unique cars
39
39
40
40
These operations would typically be done by an organizational or peer admin.
@@ -53,74 +53,66 @@ against is ``dev-peer0.org1.example.com``.
53
53
54
54
APIs are accessible with an SDK. For purposes of this exercise, we're using the
55
55
`Hyperledger Fabric Node SDK <https://fabric-sdk-node.github.io/>`__ though
56
-
there is also a Java SDK and CLI that can be used to develop applications.
56
+
there is also a Java SDK and CLI that can be used to drive transactions.
57
57
SDKs encapsulate all access to the ledger by allowing an application to
58
-
use smart contracts, run queries, or receive ledger updates. These APIs use
58
+
communicate with smart contracts, run queries, or receive ledger updates. These APIs use
59
59
several different network addresses and are run with a set of input parameters.
60
60
61
-
Smart contracts are installed and instantiated on a channel through the
62
-
consensus process. The script that launched our simplified Fabcar test network
63
-
bypassed this process by installing and instantiating the smart contracts for
64
-
us on the lone peer in our network.
65
-
66
-
One crucial aspect of networks missing from Fabcar is the roll a certificate
67
-
authority (CA) plays issuing the certificates that allow users to query,
68
-
transact, and govern a network. This simplification was made because Fabcar is
69
-
really meant to show how applications connect to the network and issue queries
70
-
and updates rather than highlighting the enrollment and governance process.
71
-
72
-
In future iterations of Fabcar we'll go more into how enrollment works and how
73
-
different kinds of certificates are issued.
61
+
Smart contracts are installed by a peer administrator and then instantiated on a
62
+
channel by an identity fulfilling the chaincode's instantiation policy, which by
63
+
default is comprised of channel administrators. The instantiation of
64
+
the smart contract follows the same transaction flow as a normal invocation - endorse,
65
+
order, validate, commit - and is a prerequisite to interacting with a chaincode
66
+
container. The script that launched our simplified Fabcar test network took care
67
+
of the installation and instantiation for us.
74
68
75
69
Query
76
70
^^^^^
77
71
78
-
Queries are the simplest kind of invocation: a call and response. Applications
79
-
can query different ledgers at the same time. Those results are returned to
80
-
the application **synchronously**. This does not necessarily ensure that each
81
-
ledger will return exactly the same information (a peer can go down, for
82
-
example, and miss updates). Given that our sample Fabcar network has only one
83
-
peer, that's not really an issue here, but it's an important consideration
84
-
when developing applications in a real world scenario.
72
+
Queries are the simplest kind of invocation: a call and response. The most common query
73
+
will interrogate the state database for the current value associated
74
+
with a key (``GetState``). However, the `chaincode shim interface <https://github.com/hyperledger/fabric/blob/release/core/chaincode/shim/interfaces.go>`__
75
+
also allows for different types of ``Get`` calls (e.g. ``GetHistoryForKey`` or ``GetCreator``).
85
76
86
-
The peers hold the hash chain (the record of updates), while the updates
87
-
themselves are stored in a separate couchDB container (which allows for the
88
-
storage of rich queries, written in JSON).
77
+
In our example, the peer holds a hash chain of all transactions and maintains
78
+
chaincode state through use of a state database, which in our case is a CouchDB container. CouchDB
79
+
provides the added functionality of rich queries, contingent upon the chaincode data (key/val pairs)
80
+
being modeled as JSON. When we call the ``GetState`` API in our smart contract, we
81
+
are retrieving the JSON value associated with a car from the CouchDB state database.
89
82
90
-
Queries are built using a **var request** -- identifying the correct ledger, the
91
-
smart contracts it will use, the search parameters etc -- and then invoking the
92
-
``chain.queryByChaincode`` API to send the query. An API called
93
-
``response_payload`` returns the result to the application.
83
+
Queries are constructed by identifying a peer, a chaincode, a channel and a set of
84
+
inputs (e.g. the key) for an available chaincode function and then utilizing the
85
+
``chain.queryByChaincode`` API to send the query to the peer. The corresponding
86
+
value to the supplied inputs is returned to the application client as a response.
94
87
95
88
Updates
96
89
^^^^^^^
97
90
98
-
Ledger updates start with an application generating a transaction proposal. A
99
-
request is constructed to identify the channel ID, function, and specific smart
100
-
contract to target for the transaction. The program then calls the
91
+
Ledger updates start with an application generating a transaction proposal. As with
92
+
query, a request is constructed to identify a peer, chaincode, channel, function, and
93
+
set of inputs for the transaction. The program then calls the
101
94
``channel.SendTransactionProposal`` API to send the transaction proposal to the
102
95
peer(s) for endorsement.
103
96
104
-
The network (i.e., the endorsing peer) returns a proposal response, which the
97
+
The network (i.e. the endorsing peer(s)) returns a proposal response, which the
105
98
application uses to build and sign a transaction request. This request is sent
106
99
to the ordering service by calling the ``channel.sendTransaction`` API. The
107
100
ordering service bundles the transaction into a block and delivers it to all
108
-
peers on a channel for validation (the Fabcar network has only one endorsing
109
-
peer and one channel).
101
+
peers on a channel for validation (the Fabcar network has only one peer and one channel).
110
102
111
103
Finally the application uses two event handler APIs: ``eh.setPeerAddr`` to
112
104
connect to the peer's event listener port and ``eh.registerTxEvent`` to
113
-
register events associated with a specific transaction ID. The
114
-
``eh.registerTxEvent`` API registers a callback for the transactionID that
115
-
checks whether ledger was updated or not.
105
+
register for events associated with a specific transaction ID. The
106
+
``eh.registerTxEvent`` API allows the application to be notified about the fate
107
+
of a transaction (i.e. valid or invalid).
116
108
117
109
For More Information
118
110
--------------------
119
111
120
112
To learn more about how a transaction flow works beyond the scope of an
121
113
application, check out :doc:`txflow`.
122
114
123
-
To get started developing chaincode, read :doc:'chaincode4ade'.
115
+
To get started developing chaincode, read :doc:`chaincode4ade`.
124
116
125
117
For more information on how endorsement policies work, check out
0 commit comments