將 Fabric Organizations 新增至網路
本主題包含將 Hyperledger Fabric 組織加入 Oracle Blockchain Platform 網路的相關資訊。
將 Fabric Organization 加入 Oracle Blockchain Platform Network 的典型工作流程
以下是 Fabric 組織和 Oracle Blockchain Platform 創辦人組織必須執行的任務,才能將 Fabric 組織加入 Oracle Blockchain Platform 網路。
作業 | 這是誰? | 描述 | 其他資訊 |
---|---|---|---|
建立 Fabric 組織的憑證檔案 | Fabric 組織 | 尋找 Fabric 組織的 Admin、CA 和 TLS 憑證資訊,並用來撰寫 JSON 憑證檔案。 | 建立 Fabric Organization 的憑證檔案 |
將 Fabric 組織的憑證檔案上傳至 Oracle Blockchain Platform 網路 | 創辦人組織 | 使用主控台上傳並匯入 Fabric 組織的憑證檔案,以便將 Fabric 組織新增至網路。 | 匯入憑證以新增組織至網路 |
建立管道 | 創辦人組織 | 建立新通道,並將 Fabric 組織新增至該通道。 | 建立管道 |
從創辦人匯出訂購服務設定 | 創辦人組織 | 將創始者的訂購服務設定輸出到 JSON 檔案,並將檔案傳送到 Fabric 組織。 | 將參加者或橫向擴展的 OSN 加入創辦人訂購服務 |
撰寫排序器憑證檔案 | Fabric 組織 | 建立一個名為 orderer.pem 的檔案,其中包含 tlscacert 資訊。
移至匯出的訂購服務設定檔案並複製 tlscacert 資訊。將 tlscacert 資訊貼到 orderer.pem 檔案之後,就必須以換行字元取代所有 \n 實例。 orderer.pem 檔案必須具有下列格式:
|
建立 Fabric Organization 的憑證檔案 |
提供訂購服務設定值 | 創辦人組織 | 開啟訂購服務設定值檔案,並尋找訂購服務的位址與連接埠,然後將它們提供給 Fabric 組織。舉例而言:
|
無 |
將 Fabric 組織新增至網路 | Fabric 組織 | Fabric 組織會將憑證複製到其環境、設定環境變數、擷取 genesis 區塊、加入通道,以及安裝鏈碼。 | 準備使用 Oracle Blockchain Platform Network 的 Fabric 環境 |
建立 Fabric Organization 的憑證檔案
對於 Fabric 組織加入 Oracle Blockchain Platform 網路,它必須撰寫包含其 admincerts、cacerts 和 tlscacerts 資訊的憑證檔案。Oracle Blockchain Platform 創辦人組織會匯入此檔案,將 Fabric 組織新增至網路。
Fabric 憑證資訊儲存在 Fabric 組織 MSP 資料夾中的 PEM 檔案中。例如,network_name_example/crypto-config/peerOrganizations/example_org.com/msp/
。
憑證檔案必須以 JSON 寫入,且必須包含下列欄位。對於所有憑證,將憑證資訊複製到 JSON 檔案中時,您必須以 \n 取代每一行,讓資訊在一行內沒有任何空格,如下列範例所示。
-
mspid - 指定 Fabric 組織的名稱。
- type - 表示組織為網路參與者。此值必須是參與者。
-
admincert - 包含組織之管理憑證檔案的內容:
Admin@example_org.com-cert.pem
。 -
cacert - 包含組織 CA 憑證檔案的內容:
ca.example_org-cert.pem
。 -
tlscacert - 包含組織 TLS 憑證檔案的內容:
tlsca.example_org-cert.pem
。 - intermediatecerts - 此可選元素包含中介 CA 憑證檔案的內容。除非有中介 CA 憑證檔案,否則請勿指定此元素。
- nodeouidentifiercert - 此區段包含識別節點 OU 角色的憑證。
-
adminouidentifiercert - 包含用於識別節點 OU 管理員角色之組織憑證檔案的內容。如果您不需要管理角色,可以使用 cacert 檔案內容或中介憑證檔案內容作為管理 ID 內容。
-
clientouidentifiercert - 包含組織用於識別節點 OU 用戶端角色的憑證檔案內容。
-
ordererouidentifiercert - 包含組織用於識別節點 OU 排序器角色的憑證檔案內容。如果您不需要排序器角色,可以使用 cacert 檔案內容或中間憑證檔案內容作為排序器識別碼內容。
-
peerouidentifiercert - 包含用於識別節點 OU 對等角色之組織憑證檔案的內容。
{
"mspID": "examplemspID",
"type": "Participant",
"certs": {
"admincert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"cacert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"tlscacert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n"
"nodeouidentifiercert": {
"adminouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"clientouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"ordererouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"peerouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n"
}
}
}
準備使用 Oracle Blockchain Platform 網路的 Fabric 環境
您必須先修改 Fabric 組織的環境,才能使用 Oracle Blockchain Platform 網路。
確認下列先決任務已完成。如需詳細資訊,請參閱將 Fabric Organization 加入 Oracle Blockchain Platform Network 的典型工作流程。
-
Fabric 組織的憑證檔案已建立並傳送給 Oracle Blockchain Platform 網路創辦人。
-
網路創始人已上傳憑證檔案,將 Fabric 組織新增至網路。
-
網路創始人建立了新的頻道,並加入了 Fabric 組織。
-
網路創辦人已下載訂購服務設定,並將其傳送到 Fabric 組織。
-
Fabric 組織已建立排序器憑證檔案。
-
網路創辦人將訂購服務位址與連接埠提供給 Fabric 組織。
您必須新增 Fabric 組織,並安裝並測試鏈碼。
-
瀏覽至 Fabric Network 目錄並啟動對等容器。
-
用以下指令抓取頻道的基因區塊 :
peer channel fetch 0 mychannel.block -o ${orderer_addr}:${orderer_port} -c mychannel --tls --cafile orderer.pem --logging-level debug
其中:
-
{orderer_addr} 是創立者的訂購者地址。
-
{orderer_port} 是創立者的連接埠號碼。
-
-c mychannel 是「創立者」建立的通道名稱。這是 Fabric 組織在 Oracle Blockchain Platform 網路上傳送和接收交易的管道。
-
orderer.pem 是創立者的訂購者憑證檔案。
-
-
使用此命令加入頻道 :
peer channel join -b mychannel.block -o ${orderer_addr}:${orderer_port} --tls --cafile orderer.pem --logging-level debug
-
使用此命令安裝鏈碼:
peer chaincode install -n mycc -v 1.0 -l "golang" -p ${CC_SRC_PATH}
其中 CC_SRC_PATH 是包含鏈碼的資料夾。
-
使用下列命令來建立鏈碼:
peer chaincode instantiate -o ${orderer_addr}:${orderer_port} --tls --cafile orderer.pem -C mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P <policy_string> --logging-level debug
-
使用下列命令呼叫鏈碼:
peer chaincode invoke -o ${orderer_addr}:${orderer_port} --tls true --cafile orderer.pem -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}' --logging-level debug
-
使用此命令查詢鏈碼:
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' --logging-level debug