2017-10-09 350 views
0

当我查看cryptogen一个结构命令)配置文件。我看到了符号。yaml中的“<<”和“&”是什么意思?

Profiles: 

    SampleInsecureSolo: 
     Orderer: 
      <<: *OrdererDefaults ## what is the `<<` 
      Organizations: 
       - *ExampleCom  ## what is the `*` 
     Consortiums: 
      SampleConsortium: 
       Organizations: 
        - *Org1ExampleCom 
        - *Org2ExampleCom 

上面有两个符号的<<*

Application: &ApplicationDefaults # what is the `&` mean 

    Organizations: 

正如你所见,还有另一个符号&。 我不知道有什么意思。我甚至没有通过审查源代码(fabric/common/configtx/tool/configtxgen/main.go

回答

1

那么得到的任何信息,这些都是YAML文件格式,它用在这里提供一个配置文件为configtxgen的元素。该“&”标志的意思是锚和“*”参考锚,这基本上是用来避免重复,例如:

person: &person 
    name: "John Doe" 

employee: &employee 
      : << *person 
    salary : 5000 

会重用的人领域,也有类似的含义:

employee: &employee 
    name : "John Doe" 
    salary : 5000 

另一示例被简单地再利用值:

key1: &key some very common value 

key2: *key 

等效于:

key1: some very common value 

key2: some very common value 

由于abric/common/configtx/tool/configtxgen/main.go使用了架子YAML解析器,因此您将无法在configtxgen相关代码中找到对这些符号的任何引用。我建议阅读更多关于YAML file format的信息。