Piotr Brudny
Piotr Brudny

Reputation: 656

Multiple peer nodes but only one dev-peer

I have a Fabric Composer network with 3 peers in one organization.

The problem is that when I do docker stats I see only one 'Chain code container' dev-peer0.org1 and as far as I know there should be dev-peer for each peer node (Extra dev peers in hyperledger fabric)

enter image description here

Here is my connection profile

{
    "name": "hlfv1",
    "x-type": "hlfv1",
    "x-commitTimeout": 300,
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300",
                    "eventHub": "300",
                    "eventReg": "300"
                },
                "orderer": "300"
            }
        }
    },
    "channels": {
        "composerchannel": {
            "orderers": [
                "orderer.example.com"
            ],
            "peers": {
                "peer0.org1.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "eventSource": true
                },
                "peer1.org1.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "eventSource": true
                },
                "peer2.org1.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "eventSource": true
                }
            }
        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "peer0.org1.example.com",
                "peer1.org1.example.com",
                "peer2.org1.example.com"
            ],
            "certificateAuthorities": [
                "ca.org1.example.com"
            ]
        }
    },
    "orderers": {
        "orderer.example.com": {
            "url": "grpc://localhost:7050"
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "grpc://localhost:7051"
        },
        "peer1.org1.example.com": {
            "url": "grpc://localhost:8051"
        },
        "peer2.org1.example.com": {
            "url": "grpc://localhost:9051"
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http://localhost:7054",
            "caName": "ca.org1.example.com"
        }
    }
}

Anybody knows what is wrong?

Upvotes: 0

Views: 267

Answers (3)

Shahid Hussain
Shahid Hussain

Reputation: 1789

Containers are created only when you instantiate the chaincode on a channel. Only installation of chaincode will not create containers.

More details about this process can be found in an official document mentioned below.(search text "dev-peer").

This document explained how the each chaincode containers are created for byfn example.

https://github.com/hyperledger/fabric/blob/release-1.4/docs/source/build_network.rst

For example:[for dev-peer0.org2.example.com-mycc-1.0]

-  The chaincode is then "instantiated" on ``mychannel``. Instantiation
   adds the chaincode to the channel, starts the container for the target peer,
   and initializes the key value pairs associated with the chaincode.  The initial
   values for this example are ["a","100" "b","200"]. **This "instantiation" results
   in a container by the name of ``dev-peer0.org2.example.com-mycc-1.0`` starting.**

Upvotes: 0

Piotr Brudny
Piotr Brudny

Reputation: 656

Got it. The problem was that I hadn't changed the startFabric.sh script so I had 3 peer nodes running but they didn't join the channel

Here is how startFabric.sh should look like:

...

# Create the channel and join for peer 0
docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b composerchannel.block

# Create the channel and join for peer 1
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.example.com peer channel fetch config -o orderer.example.com:7050 -c composerchannel
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.example.com peer channel join -b composerchannel_config.block

# Create the channel and join for peer 2
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer2.org1.example.com peer channel fetch config -o orderer.example.com:7050 -c composerchannel
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer2.org1.example.com peer channel join -b composerchannel_config.block

if [ "${FABRIC_DEV_MODE}" == "true" ]; then
    echo "Fabric Network started in chaincode development mode"
fi

Upvotes: 0

Hnampk
Hnampk

Reputation: 517

The dev-peer containers are automatically generated when a peer install chaincode and the chaincode was instantiated.

That means only the peer0.org1 in your network has a chaincode installed.

you can read the explaination of Byfn project here

Upvotes: 1

Related Questions