github.com/kaituanwang/hyperledger@v2.0.1+incompatible/docs/source/commands/configtxlator.md (about)

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