Skip to content

Commit 93e7c76

Browse files
committed
[FAB-FAB-2635]: Add orderer endpoint, for testchainid
After added an ability to read ordering service endpoint to configure delivery service to connect to the orderers, the peer cli case still generates old fashion genesis block which misses ordering service endpoint. Added -o option to configure peer cli with endpoint while running with --peer-defaultchain option. Change-Id: I5a14744fde6cd82f253646c1b934a0c06e76ee34 Signed-off-by: Artem Barger <[email protected]>
1 parent 5b48469 commit 93e7c76

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

peer/node/start.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ import (
2424
"os/signal"
2525
"path/filepath"
2626
"strconv"
27+
"strings"
2728
"syscall"
2829
"time"
2930

3031
"github.com/hyperledger/fabric/common/configtx"
3132
"github.com/hyperledger/fabric/common/configtx/test"
33+
configtxchannel "github.com/hyperledger/fabric/common/configvalues/channel"
3234
"github.com/hyperledger/fabric/common/configvalues/channel/application"
3335
"github.com/hyperledger/fabric/common/configvalues/msp"
3436
"github.com/hyperledger/fabric/common/genesis"
@@ -56,6 +58,7 @@ import (
5658

5759
var chaincodeDevMode bool
5860
var peerDefaultChain bool
61+
var orderingEndpoint string
5962

6063
func startCmd() *cobra.Command {
6164
// Set the flags on the node start command.
@@ -64,6 +67,7 @@ func startCmd() *cobra.Command {
6467
"Whether peer in chaincode development mode")
6568
flags.BoolVarP(&peerDefaultChain, "peer-defaultchain", "", true,
6669
"Whether to start peer with chain testchainid")
70+
flags.StringVarP(&orderingEndpoint, "orderer", "o", "orderer:7050", "Ordering service endpoint")
6771

6872
return nodeStartCmd
6973
}
@@ -152,7 +156,7 @@ func serve(args []string) error {
152156

153157
serializedIdentity, err := mgmt.GetLocalSigningIdentityOrPanic().Serialize()
154158
if err != nil {
155-
panic(fmt.Sprintf("Failed serializing self identity: %v", err))
159+
logger.Panicf("Failed serializing self identity: %v", err)
156160
}
157161

158162
messageCryptoService := mcs.New(
@@ -167,6 +171,14 @@ func serve(args []string) error {
167171

168172
// Begin startup of default chain
169173
if peerDefaultChain {
174+
if orderingEndpoint == "" {
175+
logger.Panic("No ordering service endpoint provided, please use -o option.")
176+
}
177+
178+
if len(strings.Split(orderingEndpoint, ":")) != 2 {
179+
logger.Panicf("Invalid format of ordering service endpoint, %s.", orderingEndpoint)
180+
}
181+
170182
chainID := util.GetTestChainID()
171183

172184
// add readers, writers and admin policies for the default chain
@@ -181,9 +193,11 @@ func serve(args []string) error {
181193
block, err := genesis.NewFactoryImpl(
182194
configtx.NewCompositeTemplate(
183195
test.ApplicationOrgTemplate(),
196+
configtx.NewSimpleTemplate(configtxchannel.TemplateOrdererAddresses([]string{orderingEndpoint})),
184197
policyTemplate)).Block(chainID)
198+
185199
if nil != err {
186-
panic(fmt.Sprintf("Unable to create genesis block for [%s] due to [%s]", chainID, err))
200+
logger.Panicf("Unable to create genesis block for [%s] due to [%s]", chainID, err)
187201
}
188202

189203
//this creates testchainid and sets up gossip

0 commit comments

Comments
 (0)