问题
I'm trying to build a Hyperledger Fabric network with the following
Smartforce[Orderer Org]
Falcon.io [ORG1]
Frost.io [ORG2]
I have generated all cryptographic materials using cryptogen tool. now looking to build gensis block using configtxgen tool.
Here is configtx.yaml
:
Profiles:
TwoOrgOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *Smartforce
Consortiums:
SampleConsortium:
Organizations:
- *BusinessPartner1
- *BusinessPartner2
TwoOrgChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *BusinessPartner1
- *BusinessPartner2
Organizations:
- &Smartforce
Name: smartforce
ID: SmartforceMSP
MSPDir: /home/falcon/iq-smartforce/crypto-config/ordererOrganizations/smartforce.io/msp
- &BusinessPartner1
Name: BusinessPartner1
ID: FalconMSP
MSPDir: /home/falcon/iq-smartforce/crypto-config/peerOrganizations/falcon.io/msp
- &BusinessPartner2
Name: BusinessPartner2
ID: FrostMSP
MSPDir: /home/frost/iq-smartforce/crypto-config/peerOrganizations/frost.io/msp
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.smartforce.io:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Organizations:
Application: &ApplicationDefaults
Organizations:
When I run the command :
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
I get the following error:
2018-12-12 14:55:55.834 IST [common/tools/configtxgen] main -> WARN 001 Omitting the channel ID for configtxgen is deprecated. Explicitly passing the channel ID will be required in the future, defaulting to 'testchainid'.
2018-12-12 14:55:55.834 IST [common/tools/configtxgen] main -> INFO 002 Loading configuration
2018-12-12 14:55:55.834 IST [common/tools/configtxgen/localconfig] Load -> CRIT 003 Error reading configuration: While parsing config: yaml: unknown anchor 'OrdererDefaults' referenced
2018-12-12 14:55:55.834 IST [common/tools/configtxgen] func1 -> CRIT 004 Error reading configuration: While parsing config: yaml: unknown anchor 'OrdererDefaults' referenced
panic: Error reading configuration: While parsing config: yaml: unknown anchor 'OrdererDefaults' referenced [recovered]
panic: Error reading configuration: While parsing config: yaml: unknown anchor 'OrdererDefaults' referenced
goroutine 1 [running]:
github.com/hyperledger/fabric/vendor/github.com/op/go-logging.(*Logger).Panic(0xc4201abe30, 0xc42048fd10, 0x1, 0x1)
/w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/vendor/github.com/op/go-logging/logger.go:188 +0xbd
main.main.func1()
/w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/configtxgen/main.go:254 +0x1ae
panic(0xc6ea00, 0xc42048fd00)
/opt/go/go1.10.linux.amd64/src/runtime/panic.go:505 +0x229
github.com/hyperledger/fabric/vendor/github.com/op/go-logging.(*Logger).Panic(0xc4201abc80, 0xc420484ae0, 0x2, 0x2)
/w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/vendor/github.com/op/go-logging/logger.go:188 +0xbd
github.com/hyperledger/fabric/common/tools/configtxgen/localconfig.Load(0x7ffdcf041294, 0x15, 0x0, 0x0, 0x0, 0x1)
/w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/configtxgen/localconfig/config.go:277 +0x469
main.main()
/w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/configtxgen/main.go:265 +0xce7
回答1:
In YAML all anchors ( those tokens starting with &
) need to precede any references to them (using aliases, the tokens starting with *
) in the file.
So in the root-level mapping you should put your key Profiles
and its value after the key Organizations
, Orderer
and Application
(and their values):
Organizations:
- &Smartforce
Name: smartforce
ID: SmartforceMSP
MSPDir: /home/falcon/iq-smartforce/crypto-config/ordererOrganizations/smartforce.io/msp
- &BusinessPartner1
Name: BusinessPartner1
ID: FalconMSP
MSPDir: /home/falcon/iq-smartforce/crypto-config/peerOrganizations/falcon.io/msp
- &BusinessPartner2
Name: BusinessPartner2
ID: FrostMSP
MSPDir: /home/frost/iq-smartforce/crypto-config/peerOrganizations/frost.io/msp
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.smartforce.io:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Organizations:
Application: &ApplicationDefaults
Organizations:
Profiles:
TwoOrgOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *Smartforce
Consortiums:
SampleConsortium:
Organizations:
- *BusinessPartner1
- *BusinessPartner2
TwoOrgChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *BusinessPartner1
- *BusinessPartner2
来源:https://stackoverflow.com/questions/53740104/configure-confixtx-yaml-file