Skip to content

Commit

Permalink
[FAB-FAB-2635]: Add orderer endpoint, for testchainid
Browse files Browse the repository at this point in the history
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 <bartem@il.ibm.com>
  • Loading branch information
C0rWin committed Mar 4, 2017
1 parent 5b48469 commit 93e7c76
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions peer/node/start.go
Expand Up @@ -24,11 +24,13 @@ import (
"os/signal"
"path/filepath"
"strconv"
"strings"
"syscall"
"time"

"github.com/hyperledger/fabric/common/configtx"
"github.com/hyperledger/fabric/common/configtx/test"
configtxchannel "github.com/hyperledger/fabric/common/configvalues/channel"
"github.com/hyperledger/fabric/common/configvalues/channel/application"
"github.com/hyperledger/fabric/common/configvalues/msp"
"github.com/hyperledger/fabric/common/genesis"
Expand Down Expand Up @@ -56,6 +58,7 @@ import (

var chaincodeDevMode bool
var peerDefaultChain bool
var orderingEndpoint string

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

return nodeStartCmd
}
Expand Down Expand Up @@ -152,7 +156,7 @@ func serve(args []string) error {

serializedIdentity, err := mgmt.GetLocalSigningIdentityOrPanic().Serialize()
if err != nil {
panic(fmt.Sprintf("Failed serializing self identity: %v", err))
logger.Panicf("Failed serializing self identity: %v", err)
}

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

// Begin startup of default chain
if peerDefaultChain {
if orderingEndpoint == "" {
logger.Panic("No ordering service endpoint provided, please use -o option.")
}

if len(strings.Split(orderingEndpoint, ":")) != 2 {
logger.Panicf("Invalid format of ordering service endpoint, %s.", orderingEndpoint)
}

chainID := util.GetTestChainID()

// add readers, writers and admin policies for the default chain
Expand All @@ -181,9 +193,11 @@ func serve(args []string) error {
block, err := genesis.NewFactoryImpl(
configtx.NewCompositeTemplate(
test.ApplicationOrgTemplate(),
configtx.NewSimpleTemplate(configtxchannel.TemplateOrdererAddresses([]string{orderingEndpoint})),
policyTemplate)).Block(chainID)

if nil != err {
panic(fmt.Sprintf("Unable to create genesis block for [%s] due to [%s]", chainID, err))
logger.Panicf("Unable to create genesis block for [%s] due to [%s]", chainID, err)
}

//this creates testchainid and sets up gossip
Expand Down

0 comments on commit 93e7c76

Please sign in to comment.