Reputation: 61
I am trying out the fabric-samples balance-transfer example, I tried to create a new channel with the below commands. The channel gets created but when I try to join the peer to the channel I get the below error. Can anyone suggest the step I am missing or going wrong
[client-utils.js]: sendPeersProposal - Promise is rejected: Error: chaincode error (status: 500, message: Cannot create ledger from genesis block, due to LedgerID already exists)
Command I used to create a new channel Config
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel.tx -channelID channel1
REST Call I am using to create the channel
curl -s -X POST http://localhost:4000/channels -H "authorization: Bearer XXXXXX" -H "content-type: application/json" -d '{ "channelName":"channel1", "channelConfigPath":"../artifacts/channel/channel.tx" }'
REST Call I am using to join the channel
curl -s -X POST http://localhost:4000/channels/channel1/peers
-H "authorization: Bearer XXXXX" -H "content-type: application/json" -d '{ "peers": ["peer1","peer2"] }'
Upvotes: 5
Views: 6425
Reputation: 12821
If you run into similar problem check if the following environment variables are set:
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=localhost:7051
Upvotes: 0
Reputation: 31
This error occurs in two different scenarios:
If the peer has already joined the channel and you are doing it again. You can run peer channel list and check whether peer has already joined the channel.
When you stop, remove docker containers, and up the containers again in docker-compose.yaml ,peer volume in the container would have stored previous data. So even though you believe you didnt create the channel, this channel information is available because of the previous volumes in the peer container. So you need to remove these volumes as well by running docker system prune --volumes -f . This removes the unused volumes and networks.
Upvotes: 0
Reputation: 333
In most instances, Cannot create ledger from genesis block, due to LedgerID already exists
, indicates that the peers have already joined the channel.
A quick way to test this, if you have instantiated chaincode on the peers, is to do a query on the ledger using one of the peers.
Upvotes: 3