github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/docs/source/commands/peerchannel.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 # peer channel 7 8 The `peer channel` command allows administrators to perform channel related 9 operations on a peer, such as joining a channel or listing the channels to which 10 a peer is joined. 11 12 ## Syntax 13 14 The `peer channel` command has the following subcommands: 15 16 * create 17 * fetch 18 * getinfo 19 * join 20 * joinbysnapshot 21 * joinbysnapshotstatus 22 * list 23 * signconfigtx 24 * update 25 26 ## peer channel 27 ``` 28 Operate a channel: create|fetch|join|joinbysnapshot|joinbysnapshotstatus|list|update|signconfigtx|getinfo. 29 30 Usage: 31 peer channel [command] 32 33 Available Commands: 34 create Create a channel 35 fetch Fetch a block 36 getinfo get blockchain information of a specified channel. 37 join Joins the peer to a channel. 38 joinbysnapshot Joins the peer to a channel by the specified snapshot 39 joinbysnapshotstatus Query if joinbysnapshot is running for any channel 40 list List of channels peer has joined. 41 signconfigtx Signs a configtx update. 42 update Send a configtx update. 43 44 Flags: 45 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 46 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 47 --clientauth Use mutual TLS when communicating with the orderer endpoint 48 --connTimeout duration Timeout for client to connect (default 3s) 49 -h, --help help for channel 50 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 51 -o, --orderer string Ordering service endpoint 52 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 53 --tls Use TLS when communicating with the orderer endpoint 54 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 55 56 Use "peer channel [command] --help" for more information about a command. 57 ``` 58 59 60 ## peer channel create 61 ``` 62 Create a channel and write the genesis block to a file. 63 64 Usage: 65 peer channel create [flags] 66 67 Flags: 68 -c, --channelID string In case of a newChain command, the channel ID to create. It must be all lower case, less than 250 characters long and match the regular expression: [a-z][a-z0-9.-]* 69 -f, --file string Configuration transaction file generated by a tool such as configtxgen for submitting to orderer 70 -h, --help help for create 71 --outputBlock string The path to write the genesis block for the channel. (default ./<channelID>.block) 72 -t, --timeout duration Channel creation timeout (default 10s) 73 74 Global Flags: 75 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 76 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 77 --clientauth Use mutual TLS when communicating with the orderer endpoint 78 --connTimeout duration Timeout for client to connect (default 3s) 79 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 80 -o, --orderer string Ordering service endpoint 81 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 82 --tls Use TLS when communicating with the orderer endpoint 83 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 84 ``` 85 86 87 ## peer channel fetch 88 ``` 89 Fetch a specified block, writing it to a file. 90 91 Usage: 92 peer channel fetch <newest|oldest|config|(number)> [outputfile] [flags] 93 94 Flags: 95 --bestEffort Whether fetch requests should ignore errors and return blocks on a best effort basis 96 -c, --channelID string In case of a newChain command, the channel ID to create. It must be all lower case, less than 250 characters long and match the regular expression: [a-z][a-z0-9.-]* 97 -h, --help help for fetch 98 99 Global Flags: 100 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 101 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 102 --clientauth Use mutual TLS when communicating with the orderer endpoint 103 --connTimeout duration Timeout for client to connect (default 3s) 104 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 105 -o, --orderer string Ordering service endpoint 106 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 107 --tls Use TLS when communicating with the orderer endpoint 108 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 109 ``` 110 111 112 ## peer channel getinfo 113 ``` 114 get blockchain information of a specified channel. Requires '-c'. 115 116 Usage: 117 peer channel getinfo [flags] 118 119 Flags: 120 -c, --channelID string In case of a newChain command, the channel ID to create. It must be all lower case, less than 250 characters long and match the regular expression: [a-z][a-z0-9.-]* 121 -h, --help help for getinfo 122 123 Global Flags: 124 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 125 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 126 --clientauth Use mutual TLS when communicating with the orderer endpoint 127 --connTimeout duration Timeout for client to connect (default 3s) 128 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 129 -o, --orderer string Ordering service endpoint 130 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 131 --tls Use TLS when communicating with the orderer endpoint 132 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 133 ``` 134 135 136 ## peer channel join 137 ``` 138 Joins the peer to a channel. 139 140 Usage: 141 peer channel join [flags] 142 143 Flags: 144 -b, --blockpath string Path to file containing genesis block 145 -h, --help help for join 146 147 Global Flags: 148 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 149 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 150 --clientauth Use mutual TLS when communicating with the orderer endpoint 151 --connTimeout duration Timeout for client to connect (default 3s) 152 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 153 -o, --orderer string Ordering service endpoint 154 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 155 --tls Use TLS when communicating with the orderer endpoint 156 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 157 ``` 158 159 160 ## peer channel joinbysnapshot 161 ``` 162 Joins the peer to a channel by the specified snapshot 163 164 Usage: 165 peer channel joinbysnapshot [flags] 166 167 Flags: 168 -h, --help help for joinbysnapshot 169 --snapshotpath string Path to the snapshot directory 170 171 Global Flags: 172 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 173 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 174 --clientauth Use mutual TLS when communicating with the orderer endpoint 175 --connTimeout duration Timeout for client to connect (default 3s) 176 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 177 -o, --orderer string Ordering service endpoint 178 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 179 --tls Use TLS when communicating with the orderer endpoint 180 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 181 ``` 182 183 184 ## peer channel joinbysnapshotstatus 185 ``` 186 Query if joinbysnapshot is running for any channel 187 188 Usage: 189 peer channel joinbysnapshotstatus [flags] 190 191 Flags: 192 -h, --help help for joinbysnapshotstatus 193 194 Global Flags: 195 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 196 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 197 --clientauth Use mutual TLS when communicating with the orderer endpoint 198 --connTimeout duration Timeout for client to connect (default 3s) 199 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 200 -o, --orderer string Ordering service endpoint 201 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 202 --tls Use TLS when communicating with the orderer endpoint 203 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 204 ``` 205 206 207 ## peer channel list 208 ``` 209 List of channels peer has joined. 210 211 Usage: 212 peer channel list [flags] 213 214 Flags: 215 -h, --help help for list 216 217 Global Flags: 218 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 219 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 220 --clientauth Use mutual TLS when communicating with the orderer endpoint 221 --connTimeout duration Timeout for client to connect (default 3s) 222 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 223 -o, --orderer string Ordering service endpoint 224 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 225 --tls Use TLS when communicating with the orderer endpoint 226 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 227 ``` 228 229 230 ## peer channel signconfigtx 231 ``` 232 Signs the supplied configtx update file in place on the filesystem. Requires '-f'. 233 234 Usage: 235 peer channel signconfigtx [flags] 236 237 Flags: 238 -f, --file string Configuration transaction file generated by a tool such as configtxgen for submitting to orderer 239 -h, --help help for signconfigtx 240 241 Global Flags: 242 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 243 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 244 --clientauth Use mutual TLS when communicating with the orderer endpoint 245 --connTimeout duration Timeout for client to connect (default 3s) 246 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 247 -o, --orderer string Ordering service endpoint 248 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 249 --tls Use TLS when communicating with the orderer endpoint 250 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 251 ``` 252 253 254 ## peer channel update 255 ``` 256 Signs and sends the supplied configtx update file to the channel. Requires '-f', '-o', '-c'. 257 258 Usage: 259 peer channel update [flags] 260 261 Flags: 262 -c, --channelID string In case of a newChain command, the channel ID to create. It must be all lower case, less than 250 characters long and match the regular expression: [a-z][a-z0-9.-]* 263 -f, --file string Configuration transaction file generated by a tool such as configtxgen for submitting to orderer 264 -h, --help help for update 265 266 Global Flags: 267 --cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint 268 --certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint 269 --clientauth Use mutual TLS when communicating with the orderer endpoint 270 --connTimeout duration Timeout for client to connect (default 3s) 271 --keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint 272 -o, --orderer string Ordering service endpoint 273 --ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer 274 --tls Use TLS when communicating with the orderer endpoint 275 --tlsHandshakeTimeShift duration The amount of time to shift backwards for certificate expiration checks during TLS handshakes with the orderer endpoint 276 ``` 277 278 ## Example Usage 279 280 ### peer channel create examples 281 282 Here's an example that uses the `--orderer` global flag on the `peer channel 283 create` command. 284 285 * Create a sample channel `mychannel` defined by the configuration transaction 286 contained in file `./createchannel.tx`. Use the orderer at `orderer.example.com:7050`. 287 288 ``` 289 peer channel create -c mychannel -f ./createchannel.tx --orderer orderer.example.com:7050 290 291 2018-02-25 08:23:57.548 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 292 2018-02-25 08:23:57.626 UTC [channelCmd] InitCmdFactory -> INFO 019 Endorser and orderer connections initialized 293 2018-02-25 08:23:57.834 UTC [channelCmd] readBlock -> INFO 020 Received block: 0 294 2018-02-25 08:23:57.835 UTC [main] main -> INFO 021 Exiting..... 295 296 ``` 297 298 Block 0 is returned indicating that the channel has been successfully created. 299 300 Here's an example of the `peer channel create` command option. 301 302 * Create a new channel `mychannel` for the network, using the orderer at ip 303 address `orderer.example.com:7050`. The configuration update transaction 304 required to create this channel is defined the file `./createchannel.tx`. 305 Wait 30 seconds for the channel to be created. 306 307 ``` 308 peer channel create -c mychannel --orderer orderer.example.com:7050 -f ./createchannel.tx -t 30s 309 310 2018-02-23 06:31:58.568 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 311 2018-02-23 06:31:58.669 UTC [channelCmd] InitCmdFactory -> INFO 019 Endorser and orderer connections initialized 312 2018-02-23 06:31:58.877 UTC [channelCmd] readBlock -> INFO 020 Received block: 0 313 2018-02-23 06:31:58.878 UTC [main] main -> INFO 021 Exiting..... 314 315 ls -l 316 317 -rw-r--r-- 1 root root 11982 Feb 25 12:24 mychannel.block 318 319 ``` 320 321 You can see that channel `mychannel` has been successfully created, as 322 indicated in the output where block 0 (zero) is added to the blockchain for 323 this channel and returned to the peer, where it is stored in the local 324 directory as `mychannel.block`. 325 326 Block zero is often called the *genesis block* as it provides the starting 327 configuration for the channel. All subsequent updates to the channel will be 328 captured as configuration blocks on the channel's blockchain, each of which 329 supersedes the previous configuration. 330 331 ### peer channel fetch example 332 333 Here's some examples of the `peer channel fetch` command. 334 335 * Using the `newest` option to retrieve the most recent channel block, and 336 store it in the file `mychannel.block`. 337 338 ``` 339 peer channel fetch newest mychannel.block -c mychannel --orderer orderer.example.com:7050 340 341 2018-02-25 13:10:16.137 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 342 2018-02-25 13:10:16.144 UTC [channelCmd] readBlock -> INFO 00a Received block: 32 343 2018-02-25 13:10:16.145 UTC [main] main -> INFO 00b Exiting..... 344 345 ls -l 346 347 -rw-r--r-- 1 root root 11982 Feb 25 13:10 mychannel.block 348 349 ``` 350 351 You can see that the retrieved block is number 32, and that the information 352 has been written to the file `mychannel.block`. 353 354 * Using the `(block number)` option to retrieve a specific block -- in this 355 case, block number 16 -- and store it in the default block file. 356 357 ``` 358 peer channel fetch 16 -c mychannel --orderer orderer.example.com:7050 359 360 2018-02-25 13:46:50.296 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 361 2018-02-25 13:46:50.302 UTC [channelCmd] readBlock -> INFO 00a Received block: 16 362 2018-02-25 13:46:50.302 UTC [main] main -> INFO 00b Exiting..... 363 364 ls -l 365 366 -rw-r--r-- 1 root root 11982 Feb 25 13:10 mychannel.block 367 -rw-r--r-- 1 root root 4783 Feb 25 13:46 mychannel_16.block 368 369 ``` 370 371 You can see that the retrieved block is number 16, and that the information 372 has been written to the default file `mychannel_16.block`. 373 374 For configuration blocks, the block file can be decoded using the 375 [`configtxlator` command](./configtxlator.html). See this command for an example 376 of decoded output. User transaction blocks can also be decoded, but a user 377 program must be written to do this. 378 379 ### peer channel getinfo example 380 381 Here's an example of the `peer channel getinfo` command. 382 383 * Get information about the local peer for channel `mychannel`. 384 385 ``` 386 peer channel getinfo -c mychannel 387 388 2018-02-25 15:15:44.135 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 389 Blockchain info: {"height":5,"currentBlockHash":"JgK9lcaPUNmFb5Mp1qe1SVMsx3o/22Ct4+n5tejcXCw=","previousBlockHash":"f8lZXoAn3gF86zrFq7L1DzW2aKuabH9Ow6SIE5Y04a4="} 390 2018-02-25 15:15:44.139 UTC [main] main -> INFO 006 Exiting..... 391 392 ``` 393 394 You can see that the latest block for channel `mychannel` is block 5. You 395 can also see the cryptographic hashes for the most recent blocks in the 396 channel's blockchain. 397 398 ### peer channel join example 399 400 Here's an example of the `peer channel join` command. 401 402 * Join a peer to the channel defined in the genesis block identified by the file 403 `./mychannel.genesis.block`. In this example, the channel block was 404 previously retrieved by the `peer channel fetch` command. 405 406 ``` 407 peer channel join -b ./mychannel.genesis.block 408 409 2018-02-25 12:25:26.511 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 410 2018-02-25 12:25:26.571 UTC [channelCmd] executeJoin -> INFO 006 Successfully submitted proposal to join channel 411 2018-02-25 12:25:26.571 UTC [main] main -> INFO 007 Exiting..... 412 413 ``` 414 415 You can see that the peer has successfully made a request to join the channel. 416 417 ### peer channel joinbysnapshot example 418 419 Here's an example of the `peer channel joinbysnapshot` command. 420 421 * Join a peer to the channel from a snapshot identified by the directory 422 `/snapshots/completed/testchannel/1000`. The snapshot was previously created on a different peer. 423 424 ``` 425 peer channel joinbysnapshot --snapshotpath /snapshots/completed/testchannel/1000 426 427 2020-10-12 11:41:45.442 EDT [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 428 2020-10-12 11:41:45.444 EDT [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 429 2020-10-12 11:41:45.444 EDT [channelCmd] joinBySnapshot -> INFO 003 The joinbysnapshot operation is in progress. Use "peer channel joinbysnapshotstatus" to check the status. 430 431 ``` 432 433 You can see that the peer has successfully made a request to join the channel from the specified snapshot. 434 When a `joinbysnapshot` operation is in progress, you cannot run another `peer channel join` 435 or `peer channel joinbysnapshot` simultaneously. To know whether or not a joinbysnapshot operation is in progress, 436 you can call the `peer channel joinbysnapshotstatus` command. 437 438 439 ### peer channel joinbysnapshotstatus example 440 441 Here are some examples of the `peer channel joinbysnapshotstatus` command. 442 443 * Query if joinbysnapshot is in progress for any channel. If yes, 444 it returns a message indicating a joinbysnapshot operation is in progress. 445 446 ``` 447 peer channel joinbysnapshotstatus 448 449 2020-10-12 11:41:45.952 EDT [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 450 A joinbysnapshot operation is in progress for snapshot at /snapshots/completed/testchannel/1000 451 ``` 452 453 * If no `joinbysnapshot` operation is in progress, it returns a message indicating no joinbysnapshot operation is in progress. 454 455 ``` 456 peer channel joinbysnapshotstatus 457 458 2020-10-12 11:41:47.922 EDT [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 459 No joinbysnapshot operation is in progress 460 461 ``` 462 463 ### peer channel list example 464 465 Here's an example of the `peer channel list` command. 466 467 * List the channels to which a peer is joined. 468 469 ``` 470 peer channel list 471 472 2018-02-25 14:21:20.361 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 473 Channels peers has joined: 474 mychannel 475 2018-02-25 14:21:20.372 UTC [main] main -> INFO 006 Exiting..... 476 477 ``` 478 479 You can see that the peer is joined to channel `mychannel`. 480 481 ### peer channel signconfigtx example 482 483 Here's an example of the `peer channel signconfigtx` command. 484 485 * Sign the `channel update` transaction defined in the file 486 `./updatechannel.tx`. The example lists the configuration transaction file 487 before and after the command. 488 489 ``` 490 ls -l 491 492 -rw-r--r-- 1 anthonyodowd staff 284 25 Feb 18:16 updatechannel.tx 493 494 peer channel signconfigtx -f updatechannel.tx 495 496 2018-02-25 18:16:44.456 GMT [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 497 2018-02-25 18:16:44.459 GMT [main] main -> INFO 002 Exiting..... 498 499 ls -l 500 501 -rw-r--r-- 1 anthonyodowd staff 2180 25 Feb 18:16 updatechannel.tx 502 503 ``` 504 505 You can see that the peer has successfully signed the configuration 506 transaction by the increase in the size of the file `updatechannel.tx` from 507 284 bytes to 2180 bytes. 508 509 ### peer channel update example 510 511 Here's an example of the `peer channel update` command. 512 513 * Update the channel `mychannel` using the configuration transaction defined in 514 the file `./updatechannel.tx`. Use the orderer at ip address 515 `orderer.example.com:7050` to send the configuration transaction to all peers 516 in the channel to update their copy of the channel configuration. 517 518 ``` 519 peer channel update -c mychannel -f ./updatechannel.tx -o orderer.example.com:7050 520 521 2018-02-23 06:32:11.569 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 522 2018-02-23 06:32:11.626 UTC [main] main -> INFO 010 Exiting..... 523 524 ``` 525 526 At this point, the channel `mychannel` has been successfully updated. 527 528 <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>.