# Network Configuration Tools - configtxlator & .jq


## Network configuration workflow
- Configuration Update workflow:

- configuration updates are made by first fetching the current configuration & then edition it
| Web Apps | Fabric |
| ------------------------------------------------------------ | ------------------------------------------------- |
| configuration files in Source code repositories e.g., GitHub | configuration stored as transaction in the Ledger |
- ALWAYS fetch the latest config from Ledger
- Update the fetched config and send as Transaction
- Update step
1. Fetch the Latest configuration & update it

3. Submit the update transaction to Orderer

## Network configxlator tool
- configxlator = Configuration + Translator
used by the administrators for managing the configuration updates for Fabric

- configxlator modes
same binary used to luanching CLI & REST Server
- Command Line Interface
`configtxlator command --flags`
command:
- `proto_decode`
Protocol Buffers --> JSON
- `proto_encode`
JSON --> Protocol Buffers
- `--type`:
type of proto buffer structure to endcode/decode
- `common.Block`
Block format
- `common.Config`
Configuraiton transaction
- `Envelope`
Transaction enclosed in message envelope
- `ConfigUpdate`
Update config transaction message format
- `Policy`
Policy message format
- `--input`
Protocol Buffer file or JSON file
- `--output`
JSON file or Protocol Buffer file
- `compute_update`
Compute DELTA between two Protocol Buffers
- `--original`
original config ProtoBuf fetched from network
- `--updated`
updated config ProtoBuf
- `--channel_id`
Channel ID
- [REST Server](https://zh.wikipedia.org/wiki/%E8%A1%A8%E7%8E%B0%E5%B1%82%E7%8A%B6%E6%80%81%E8%BD%AC%E6%8D%A2)
`configtxlator start --hostname localhost --port 7059`
- config translator is launched as a REST server
- command are excuted by using the CURL utility
:::warning
Unlike the other bibaries for Fabric, there is no **configuration file** for config translator
:::
## ./jq Utility

- Command Line Processor for JSON data
- Slice & filter data
- Transform the data
- Install
`sudo apt-get install jq`
- Available online for learning | trying
https://jqplay.org/

- Using the CLI
`cat file.json | jq expression`
e.g.
`cat test.json | jq .data.data[0].playload.header.channel_header`

`cat test.json | jq .data.data[0].playload.header.channel_header > test1.json`
