Intelligent contract section
Too sleepy, vacation time and then paste the chart .....
Run docker container inside, if you need to debug mode you can only play log log
A contract, that is, a user with a document prepared by the go / java / node (including: character, method, return information)
Block ( the chaincode directory), a contract can only correspond to a directory
The following directory of useful go / java / node code intelligence language development contract
The following URL can view the data stored with the channel, etc. (a contract with a channel will generate a library)
A lower channel may be mounted a plurality of contracts, each contract will generate a database
Installation Contract
Command line
Explanation:
-n: Contract Name
-v: Contract version
-p: Contracts directory
Description:
Directory contract from github.com start, because the front will automatically spell from the root directory (opt) directory on the path layer
After installation, view the status of
---------------------------------------------------------------------------------------------------------------------------
Examples of contract
Examples of operation will be saved to the chain block, which needs to be specified in the upload channel inside the block.
instruction:
Description: -n, -v same with the above instructions
-o: Specifies the order of the node // block operation must only order node
--tls --cafile: // specify tls certificate to ensure the security of data
-c: performing the method name parameter // - c '{ "Args": [ "init"]}'
-P: // policy above specified multiple instruction means only one node
After instantiation, state View
After the example of integrity, can trigger contract
Upload a contract to which the data [ invoke] command
Just upload the data query call from [contract] method definition
Call custom query methods, results
By viewing the data uploaded create database
Contract code debugging ( log print mode)
Upgrade Contract
Scenario: add new features, new optimization
You do not need to instantiate
1, the code modification code
2, reinstall the current contract (changes version 2.0)
3, call update command (generated in a tile block chain)
a, before upgrading to query the current channel block information
Results: height = 9
b, upgrading instruction execution
c, and then query a channel block information after the upgrade, look no height increases
Note: After the update, call query method of the original contract, get all the latest data, the original version of the data void
Contracts in the private data (field) can only deal with [designated organization to view]
The use of private data
1, modify the code contract
Call when api storage and value, into saving private data api
2, defines a json
Description:
name: private field name
policy: the policy (which allows access to the organization)
requiredPeerCount: In addition to multiple nodes, which nodes also serve as a backup store private data
The maximum number of private data backup: maxPeerCount
blockToLive: After private data stored on the chain and increase? Blocks, the current private data disappears (0: never disappear)
memberOnlyRead: Only members of the organization have access to the currently defined
3, the specified instance of the contract path
Note: All policies are instantiated when specified