2017-10-09 33 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的信息。