github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/docs/source/commands/configtxlator.md (about) 1 <!--- 2 File generated by help_docs.sh. DO NOT EDIT. 3 Please make changes to preamble and postscript wrappers as appropriate. 4 ---> 5 6 # configtxlator 7 8 The `configtxlator` command allows users to translate between protobuf and JSON 9 versions of fabric data structures and create config updates. The command may 10 either start a REST server to expose its functions over HTTP or may be utilized 11 directly as a command line tool. 12 13 ## Syntax 14 15 The `configtxlator` tool has five sub-commands, as follows: 16 17 * start 18 * proto_encode 19 * proto_decode 20 * compute_update 21 * version 22 23 ## configtxlator start 24 ``` 25 usage: configtxlator start [<flags>] 26 27 Start the configtxlator REST server 28 29 Flags: 30 --help Show context-sensitive help (also try --help-long and 31 --help-man). 32 --hostname="0.0.0.0" The hostname or IP on which the REST server will listen 33 --port=7059 The port on which the REST server will listen 34 --CORS=CORS ... Allowable CORS domains, e.g. '*' or 'www.example.com' 35 (may be repeated). 36 ``` 37 38 39 ## configtxlator proto_encode 40 ``` 41 usage: configtxlator proto_encode --type=TYPE [<flags>] 42 43 Converts a JSON document to protobuf. 44 45 Flags: 46 --help Show context-sensitive help (also try --help-long and 47 --help-man). 48 --type=TYPE The type of protobuf structure to encode to. For 49 example, 'common.Config'. 50 --input=/dev/stdin A file containing the JSON document. 51 --output=/dev/stdout A file to write the output to. 52 ``` 53 54 55 ## configtxlator proto_decode 56 ``` 57 usage: configtxlator proto_decode --type=TYPE [<flags>] 58 59 Converts a proto message to JSON. 60 61 Flags: 62 --help Show context-sensitive help (also try --help-long and 63 --help-man). 64 --type=TYPE The type of protobuf structure to decode from. For 65 example, 'common.Config'. 66 --input=/dev/stdin A file containing the proto message. 67 --output=/dev/stdout A file to write the JSON document to. 68 ``` 69 70 71 ## configtxlator compute_update 72 ``` 73 usage: configtxlator compute_update --channel_id=CHANNEL_ID [<flags>] 74 75 Takes two marshaled common.Config messages and computes the config update which 76 transitions between the two. 77 78 Flags: 79 --help Show context-sensitive help (also try --help-long and 80 --help-man). 81 --original=ORIGINAL The original config message. 82 --updated=UPDATED The updated config message. 83 --channel_id=CHANNEL_ID The name of the channel for this update. 84 --output=/dev/stdout A file to write the JSON document to. 85 ``` 86 87 88 ## configtxlator version 89 ``` 90 usage: configtxlator version 91 92 Show version information 93 94 Flags: 95 --help Show context-sensitive help (also try --help-long and --help-man). 96 ``` 97 98 ## Examples 99 100 ### Decoding 101 102 Decode a block named `fabric_block.pb` to JSON and print to stdout. 103 104 ``` 105 configtxlator proto_decode --input fabric_block.pb --type common.Block 106 ``` 107 108 Alternatively, after starting the REST server, the following curl command 109 performs the same operation through the REST API. 110 111 ``` 112 curl -X POST --data-binary @fabric_block.pb "${CONFIGTXLATOR_URL}/protolator/decode/common.Block" 113 ``` 114 115 ### Encoding 116 117 Convert a JSON document for a policy from stdin to a file named `policy.pb`. 118 119 ``` 120 configtxlator proto_encode --type common.Policy --output policy.pb 121 ``` 122 123 Alternatively, after starting the REST server, the following curl command 124 performs the same operation through the REST API. 125 126 ``` 127 curl -X POST --data-binary /dev/stdin "${CONFIGTXLATOR_URL}/protolator/encode/common.Policy" > policy.pb 128 ``` 129 130 ### Pipelines 131 132 Compute a config update from `original_config.pb` and `modified_config.pb` and decode it to JSON to stdout. 133 134 ``` 135 configtxlator compute_update --channel_id testchan --original original_config.pb --updated modified_config.pb | configtxlator proto_decode --type common.ConfigUpdate 136 ``` 137 138 Alternatively, after starting the REST server, the following curl commands 139 perform the same operations through the REST API. 140 141 ``` 142 curl -X POST -F channel=testchan -F "original=@original_config.pb" -F "updated=@modified_config.pb" "${CONFIGTXLATOR_URL}/configtxlator/compute/update-from-configs" | curl -X POST --data-binary /dev/stdin "${CONFIGTXLATOR_URL}/protolator/decode/common.ConfigUpdate" 143 ``` 144 145 ## Additional Notes 146 147 The tool name is a portmanteau of *configtx* and *translator* and is intended to 148 convey that the tool simply converts between different equivalent data 149 representations. It does not generate configuration. It does not submit or 150 retrieve configuration. It does not modify configuration itself, it simply 151 provides some bijective operations between different views of the configtx 152 format. 153 154 There is no configuration file `configtxlator` nor any authentication or 155 authorization facilities included for the REST server. Because `configtxlator` 156 does not have any access to data, key material, or other information which 157 might be considered sensitive, there is no risk to the owner of the server in 158 exposing it to other clients. However, because the data sent by a user to 159 the REST server might be confidential, the user should either trust the 160 administrator of the server, run a local instance, or operate via the CLI. 161 162 <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.