github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/docs/source/commands/ledgerutil.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 # ledgerutil 7 8 The `ledgerutil compare` command allows administrators to compare channel snapshots from two different peers. 9 Although channel snapshots from the same height should be identical across peers, if the snapshot 10 files indicate different state hashes (as seen in `_snapshot_signable_metadata.json` file from each snapshot) 11 then it indicates that at least one of the peers state databases is not correct relative to the blockchain and 12 may have gotten corrupted. 13 14 The `ledgerutil compare` utility will output a set of JSON files if the snapshots are not identical to assist with troubleshooting in these situations. 15 Two output JSON files will include any key/value differences sorted by key (one for public key/value differences and one for private key/value differences), 16 another JSON file will include any key/value differences (public or private) sorted by block and transaction height so that you can identify the height where a divergence may have first occurred. 17 18 The output files may help an administrator to understand the scope of a state database issue and identify which keys are impacted. 19 Snapshots from additional peers can be compared to determine which peer has incorrect state. 20 The block and transaction height of the first difference can be used as a reference point when looking at the peer's logs to understand what may have happened to the state database at that time. 21 22 ## Syntax 23 24 The `ledgerutil` command has one subcommand 25 26 * compare 27 28 ## ledgerutil compare 29 ``` 30 usage: ledgerutil compare [<flags>] <snapshotPath1> <snapshotPath2> 31 32 Compare channel snapshots from two different peers. 33 34 Flags: 35 --help Show context-sensitive help (also try --help-long 36 and --help-man). 37 -o, --outputDir=OUTPUTDIR Snapshot comparison json results output directory. 38 Default is the current directory. 39 -f, --firstDiffs=10 Maximum number of differences to record in 40 first_diffs_by_height.json. Requesting a report 41 with many differences may result in a large amount 42 of memory usage. Defaults to 10. If set to 0, will 43 not produce first_diffs_by_height.json. 44 45 Args: 46 <snapshotPath1> First ledger snapshot directory. 47 <snapshotPath2> Second ledger snapshot directory. 48 ``` 49 50 ## Example Usage 51 52 ### ledgerutil compare example 53 54 Here is an example of the `ledgerutil compare` command. 55 56 * Compare snapshots from two different peers for mychannel at snapshot height 5. 57 58 ``` 59 ledgerutil compare -o ./compare_output -f 10 ./peer0.org1.example.com/snapshots/completed/mychannel/5 ./peer1.org1.example.com/snapshots/completed/mychannel/5 60 61 Both snapshot public state and private state hashes were the same. No results were generated. 62 63 ``` 64 65 The response above indicates that the snapshots are identical. If the snapshots were not identical, the command results will indicate where the comparison output files are written, for example: 66 67 ``` 68 Successfully compared snapshots. Results saved to compare_output/mychannel_5_comparison. Total differences found: 3 69 ``` 70 71 * Note that both snapshot locations must be accessible by the command, for example by mounting volumes from two different peers, or by copying the snapshots to a common location. 72 73 <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>.