Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ GO_TAGS ?=
RELEASE_EXES = orderer $(TOOLS_EXES)
RELEASE_IMAGES = baseos ccenv orderer peer
RELEASE_PLATFORMS = darwin-amd64 darwin-arm64 linux-amd64 linux-arm64 windows-amd64
TOOLS_EXES = configtxgen configtxlator cryptogen discover ledgerutil osnadmin peer
TOOLS_EXES = configtxgen configtxlator cryptogen discover ledgerutil osnadmin peer peercli

pkgmap.configtxgen := $(PKGNAME)/cmd/configtxgen
pkgmap.configtxlator := $(PKGNAME)/cmd/configtxlator
Expand All @@ -96,6 +96,7 @@ pkgmap.ledgerutil := $(PKGNAME)/cmd/ledgerutil
pkgmap.orderer := $(PKGNAME)/cmd/orderer
pkgmap.osnadmin := $(PKGNAME)/cmd/osnadmin
pkgmap.peer := $(PKGNAME)/cmd/peer
pkgmap.peercli := $(PKGNAME)/cmd/peercli

.DEFAULT_GOAL := all

Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.e
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n basicgo --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"InitLedger","Args":[]}'
peercli chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n basicgo --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"InitLedger","Args":[]}'

peer chaincode query -C mychannel -n basicgo -c '{"Args":["GetAllAssets"]}'
peercli chaincode query -C mychannel -n basicgo -c '{"Args":["GetAllAssets"]}'

docker logs peer0.org1.example.com

Expand Down
13 changes: 8 additions & 5 deletions cmd/peer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ func main() {

mainCmd.AddCommand(version.Cmd())
mainCmd.AddCommand(node.Cmd())
mainCmd.AddCommand(chaincode.Cmd(nil, cryptoProvider))
mainCmd.AddCommand(channel.Cmd(nil))
mainCmd.AddCommand(lifecycle.Cmd(cryptoProvider))
mainCmd.AddCommand(snapshot.Cmd(cryptoProvider))

// Deprecated: use peercli
mainCmd.AddCommand(chaincode.Cmd(nil, cryptoProvider, false))
// Deprecated: use peercli or osnadmin
mainCmd.AddCommand(channel.Cmd(nil, false))
// Deprecated: use peercli
mainCmd.AddCommand(lifecycle.Cmd(cryptoProvider, false))
// Deprecated: use peercli
mainCmd.AddCommand(snapshot.Cmd(cryptoProvider, false))
// On failure Cobra prints the usage message and error string, so we only
// need to exit with a non-0 status
if mainCmd.Execute() != nil {
Expand Down
61 changes: 61 additions & 0 deletions cmd/peercli/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package main

import (
_ "net/http/pprof"
"os"
"strings"

"github.com/hyperledger/fabric-lib-go/bccsp/factory"
"github.com/hyperledger/fabric/internal/peer/chaincode"
"github.com/hyperledger/fabric/internal/peer/channel"
"github.com/hyperledger/fabric/internal/peer/common"
"github.com/hyperledger/fabric/internal/peer/lifecycle"
"github.com/hyperledger/fabric/internal/peer/snapshot"
"github.com/hyperledger/fabric/internal/peer/version"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// The main command describes the service and
// defaults to printing the help message.
var mainCmd = &cobra.Command{Use: "peercli"}

func main() {
setEnvConfig(viper.GetViper())

// Define command-line flags that are valid for all peercli commands and
// subcommands.
mainFlags := mainCmd.PersistentFlags()

mainFlags.String("logging-level", "", "Legacy logging level flag")
viper.BindPFlag("logging_level", mainFlags.Lookup("logging-level"))
mainFlags.MarkHidden("logging-level")

cryptoProvider := factory.GetDefault()

mainCmd.AddCommand(version.Cmd())
mainCmd.AddCommand(chaincode.Cmd(nil, cryptoProvider, true))
mainCmd.AddCommand(channel.Cmd(nil, true))
mainCmd.AddCommand(lifecycle.Cmd(cryptoProvider, true))
mainCmd.AddCommand(snapshot.Cmd(cryptoProvider, true))

// On failure Cobra prints the usage message and error string, so we only
// need to exit with a non-0 status
if mainCmd.Execute() != nil {
os.Exit(1)
}
}

func setEnvConfig(v *viper.Viper) {
v.SetEnvPrefix(common.CmdRoot)
v.AllowEmptyEnv(true)
v.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
v.SetEnvKeyReplacer(replacer)
}
31 changes: 31 additions & 0 deletions cmd/peercli/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package main

import (
"testing"

"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestSetEnvConfig(t *testing.T) {
vp := viper.New()
t.Setenv("CORE_FRUIT", "Apple")
t.Setenv("CORE_COLOR", "")
err := vp.BindEnv("Fruit")
require.NoError(t, err)
err = vp.BindEnv("Color")
require.NoError(t, err)
vp.SetDefault("Color", "Green")

setEnvConfig(vp)

assert.Equal(t, "Apple", vp.Get("Fruit"))
assert.Equal(t, "", vp.Get("Color"))
}
6 changes: 3 additions & 3 deletions core/chaincode/platforms/golang/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (p *Platform) Name() string {
// ValidatePath is used to ensure that path provided points to something that
// looks like go chainccode.
//
// NOTE: this is only used at the _client_ side by the peer CLI.
// NOTE: this is only used at the _client_ side by the peercli.
func (p *Platform) ValidatePath(rawPath string) error {
_, err := DescribeCode(rawPath)
if err != nil {
Expand All @@ -52,7 +52,7 @@ func (p *Platform) ValidatePath(rawPath string) error {
// NormalizePath is used to extract a relative module path from a module root.
// This should not impact legacy GOPATH chaincode.
//
// NOTE: this is only used at the _client_ side by the peer CLI.
// NOTE: this is only used at the _client_ side by the peercli.
func (p *Platform) NormalizePath(rawPath string) (string, error) {
modInfo, err := moduleInfo(rawPath)
if err != nil {
Expand Down Expand Up @@ -113,7 +113,7 @@ var gzipCompressionLevel = gzip.DefaultCompression
// GetDeploymentPayload creates a gzip compressed tape archive that contains the
// required assets to build and run go chaincode.
//
// NOTE: this is only used at the _client_ side by the peer CLI.
// NOTE: this is only used at the _client_ side by the peercli.
func (p *Platform) GetDeploymentPayload(codepath string) ([]byte, error) {
codeDescriptor, err := DescribeCode(codepath)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/ledger/kvledger/kv_ledger_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (p *Provider) Close() {

// deletePartialLedgers scans for and deletes any ledger with a status of UNDER_CONSTRUCTION or UNDER_DELETION.
// UNDER_CONSTRUCTION ledgers represent residual structures created as a side effect of a crash during ledger creation.
// UNDER_DELETION ledgers represent residual structures created as a side effect of a crash during a peer channel unjoin.
// UNDER_DELETION ledgers represent residual structures created as a side effect of a crash during a peercli channel unjoin.
func (p *Provider) deletePartialLedgers() error {
logger.Debug("Removing ledgers in state UNDER_CONSTRUCTION or UNDER_DELETION")
itr := p.idStore.db.GetIterator(metadataKeyPrefix, metadataKeyStop)
Expand Down
8 changes: 7 additions & 1 deletion docs/source/command_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ Commands Reference
commands/peerlifecycle.md
commands/peerchannel.md
commands/peersnapshot.md
commands/peerversion.md
commands/peernode.md
commands/peerversion.md
commands/peerclicommand.md
commands/peerclichaincode.md
commands/peerclilifecycle.md
commands/peerclichannel.md
commands/peerclisnapshot.md
commands/peercliversion.md
commands/osnadminchannel.md
commands/configtxgen.md
commands/configtxlator.md
Expand Down
4 changes: 2 additions & 2 deletions docs/source/commands/peerchaincode.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ localhost:7051"`.

## peer chaincode invoke
```
Invoke the specified chaincode. It will try to commit the endorsed transaction to the network.
[DEPRECATED] Invoke the specified chaincode. It will try to commit the endorsed transaction to the network. Instead of this command, use "peercli chaincode invoke".

Usage:
peer chaincode invoke [flags]
Expand Down Expand Up @@ -110,7 +110,7 @@ Global Flags:

## peer chaincode query
```
Get endorsed result of chaincode function call and print it. It won't generate transaction.
[DEPRECATED] Get endorsed result of chaincode function call and print it. It won't generate transaction. Instead of this command, use "peercli chaincode query".

Usage:
peer chaincode query [flags]
Expand Down
36 changes: 18 additions & 18 deletions docs/source/commands/peerchannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ The `peer channel` command has the following subcommands:

## peer channel
```
Operate a channel: create|fetch|join|joinbysnapshot|joinbysnapshotstatus|list|update|signconfigtx|getinfo.
[DEPRECATED] Operate a channel: create|fetch|join|joinbysnapshot|joinbysnapshotstatus|list|update|signconfigtx|getinfo. Instead of this command, use "peercli channel".

Usage:
peer channel [command]

Available Commands:
create [DEPRECATED] Create a channel
fetch Fetch a block
getinfo get blockchain information of a specified channel.
join Joins the peer to a channel.
joinbysnapshot Joins the peer to a channel by the specified snapshot
joinbysnapshotstatus Query if joinbysnapshot is running for any channel
list List of channels peer has joined.
signconfigtx Signs a configtx update.
update Send a configtx update.
create [DEPRECATED] Create a channel (use the "osnadmin join").
fetch [DEPRECATED] Fetch a block (use the "peercli channel fetch" or "osnadmin fetch").
getinfo [DEPRECATED] get blockchain information of a specified channel (use the "peercli channel getinfo").
join [DEPRECATED] Joins the peer to a channel (use the "peercli channel join").
joinbysnapshot [DEPRECATED] Joins the peer to a channel by the specified snapshot (use the "peercli channel joinbysnapshot").
joinbysnapshotstatus [DEPRECATED] Query if joinbysnapshot is running for any channel (use the "peercli channel joinbysnapshotstatus").
list [DEPRECATED] List of channels peer has joined (use the "peercli channel list").
signconfigtx [DEPRECATED] Signs a configtx update (use the "peercli channel signconfigtx").
update [DEPRECATED] Send a configtx update (use the "osnadmin update").

Flags:
--cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
Expand Down Expand Up @@ -86,7 +86,7 @@ Global Flags:

## peer channel fetch
```
Fetch a specified block, writing it to a file.
[DEPRECATED] Fetch a specified block from peer or orderer, writing it to a file. Instead of this command, use "peercli channel fetch" or "osnadmin fetch".

Usage:
peer channel fetch <newest|oldest|config|(number)> [outputfile] [flags]
Expand All @@ -111,7 +111,7 @@ Global Flags:

## peer channel getinfo
```
get blockchain information of a specified channel. Requires '-c'.
[DEPRECATED] get blockchain information of a specified channel. Requires '-c'. Instead of this command, use "peercli channel getinfo".

Usage:
peer channel getinfo [flags]
Expand All @@ -135,7 +135,7 @@ Global Flags:

## peer channel join
```
Joins the peer to a channel.
[DEPRECATED] Joins the peer to a channel. Instead of this command, use "peercli channel join".

Usage:
peer channel join [flags]
Expand All @@ -159,7 +159,7 @@ Global Flags:

## peer channel joinbysnapshot
```
Joins the peer to a channel by the specified snapshot
[DEPRECATED] Joins the peer to a channel by the specified snapshot. Instead of this command, use "peercli channel joinbysnapshot".

Usage:
peer channel joinbysnapshot [flags]
Expand All @@ -183,7 +183,7 @@ Global Flags:

## peer channel joinbysnapshotstatus
```
Query if joinbysnapshot is running for any channel
[DEPRECATED] Query if joinbysnapshot is running for any channel. Instead of this command, use "peercli channel joinbysnapshotstatus".

Usage:
peer channel joinbysnapshotstatus [flags]
Expand All @@ -206,7 +206,7 @@ Global Flags:

## peer channel list
```
List of channels peer has joined.
[DEPRECATED] List of channels peer has joined. Instead of this command, use "peercli channel list".

Usage:
peer channel list [flags]
Expand All @@ -229,7 +229,7 @@ Global Flags:

## peer channel signconfigtx
```
Signs the supplied configtx update file in place on the filesystem. Requires '-f'.
[DEPRECATED] Signs the supplied configtx update file in place on the filesystem. Requires '-f'. Instead of this command, use "peercli channel signconfigtx".

Usage:
peer channel signconfigtx [flags]
Expand All @@ -253,7 +253,7 @@ Global Flags:

## peer channel update
```
Signs and sends the supplied configtx update file to the channel. Requires '-f', '-o', '-c'.
[DEPRECATED] Signs and sends the supplied configtx update file to the channel. Requires '-f', '-o', '-c'. . Instead of this command, use Orderer Service Node (OSN).

Usage:
peer channel update [flags]
Expand Down
Loading