-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contract support for Fabric v2.0.0 (contributes to IBM-Blockchain-Arc…
…hive#94) Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
- Loading branch information
Simon Stone
committed
Jan 16, 2020
1 parent
8205f48
commit 80183d7
Showing
14 changed files
with
203 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
- name: Select peer to use for approve operations | ||
set_fact: | ||
peer: "{{ member.endorsing_peers[0] }}" | ||
|
||
- name: Approve contract | ||
command: > | ||
peer lifecycle chaincode approveformyorg | ||
-C {{ channel.name }} | ||
-n {{ definition.name }} | ||
-v {{ definition.version }} | ||
--package-id {{ package_id }} | ||
--sequence {{ sequence_number }} | ||
-o {{ ibp[channel.orderer.id].hostname }}:{{ ibp[channel.orderer.id].port }} | ||
{{ '--tls' if ibp[channel.orderer.id].protocol == 'grpcs' else '' }} | ||
{{ '--cafile "' + ibp[channel.orderer.id].pem + '"' if ibp[channel.orderer.id].protocol == 'grpcs' else '' }} | ||
{{ '--ordererTLSHostnameOverride ' + ibp[channel.orderer.id].internal_hostname if ibp[channel.orderer.id].internal_hostname is defined else '' }} | ||
environment: | ||
CORE_PEER_ADDRESS: "{{ ibp[peer.id].hostname }}:{{ ibp[peer.id].port }}" | ||
CORE_PEER_MSPCONFIGPATH: "{{ member.wallet }}/{{ member.msp.admin.identity }}" | ||
CORE_PEER_LOCALMSPID: "{{ member.msp.id }}" | ||
CORE_PEER_TLS_ENABLED: "{{ 'true' if peer.tls.enabled else 'false' }}" | ||
CORE_PEER_TLS_ROOTCERT_FILE: "{{ ibp[peer.id].pem if ibp[peer.id].pem is defined }}" | ||
changed_when: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
- name: Approve contract for all members in channel | ||
include_tasks: approve-contract-member.yml | ||
when: member.endorsing_peers is defined | ||
with_items: "{{ definition.endorsing_members }}" | ||
loop_control: | ||
loop_var: member |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
- name: Select member to use for query operations | ||
set_fact: | ||
member: "{{ definition.endorsing_members[0] }}" | ||
|
||
- name: Select peer to use for query operations | ||
set_fact: | ||
peer: "{{ member.endorsing_peers[0] }}" | ||
|
||
- name: Retrieve current committed contract list | ||
command: > | ||
peer lifecycle chaincode querycommitted | ||
-C {{ channel.name }} | ||
-n {{ definition.name }} | ||
-O json | ||
environment: | ||
CORE_PEER_ADDRESS: "{{ ibp[peer.id].hostname }}:{{ ibp[peer.id].port }}" | ||
CORE_PEER_MSPCONFIGPATH: "{{ member.wallet }}/{{ member.msp.admin.identity }}" | ||
CORE_PEER_LOCALMSPID: "{{ member.msp.id }}" | ||
CORE_PEER_TLS_ENABLED: "{{ 'true' if peer.tls.enabled else 'false' }}" | ||
CORE_PEER_TLS_ROOTCERT_FILE: "{{ ibp[peer.id].pem if ibp[peer.id].pem is defined }}" | ||
register: querycommitted | ||
failed_when: False | ||
changed_when: False | ||
|
||
- name: Load existing chaincode definition | ||
set_fact: | ||
committed_chaincode: "{{ querycommitted.stdout | from_json }}" | ||
new_sequence_number_reqd: False | ||
when: querycommitted.rc == 0 | ||
|
||
- name: Handle new chaincode definition | ||
set_fact: | ||
new_sequence_number_reqd: True | ||
when: querycommitted.rc != 0 | ||
|
||
- name: Load existing sequence number | ||
set_fact: | ||
existing_sequence_number: "{{ (committed_chaincode | default({ 'sequence': 0 })).sequence }}" | ||
when: not new_sequence_number_reqd | ||
|
||
- name: Determine if version has changed | ||
set_fact: | ||
new_sequence_number_reqd: True | ||
when: not new_sequence_number_reqd and committed_chaincode.version != definition.version | ||
|
||
- name: Set next sequence number | ||
set_fact: | ||
sequence_number: "{{ existing_sequence_number + 1 }}" | ||
when: new_sequence_number_reqd | ||
|
||
- name: Use existing sequence number | ||
set_fact: | ||
sequence_number: "{{ existing_sequence_number }}" | ||
when: not new_sequence_number_reqd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
- name: Select member to use for commit operation | ||
set_fact: | ||
member: "{{ definition.endorsing_members[0] }}" | ||
|
||
- name: Select peer to use for commit operation | ||
set_fact: | ||
peer: "{{ member.endorsing_peers[0] }}" | ||
|
||
- name: Commit contract | ||
command: > | ||
peer lifecycle chaincode commit | ||
-C {{ channel.name }} | ||
-n {{ definition.name }} | ||
-v {{ definition.version }} | ||
--sequence {{ sequence_number }} | ||
-o {{ ibp[channel.orderer.id].hostname }}:{{ ibp[channel.orderer.id].port }} | ||
{{ '--tls' if ibp[channel.orderer.id].protocol == 'grpcs' else '' }} | ||
{{ '--cafile "' + ibp[channel.orderer.id].pem + '"' if ibp[channel.orderer.id].protocol == 'grpcs' else '' }} | ||
{{ '--ordererTLSHostnameOverride ' + ibp[channel.orderer.id].internal_hostname if ibp[channel.orderer.id].internal_hostname is defined else '' }} | ||
environment: | ||
CORE_PEER_ADDRESS: "{{ ibp[peer.id].hostname }}:{{ ibp[peer.id].port }}" | ||
CORE_PEER_MSPCONFIGPATH: "{{ member.wallet }}/{{ member.msp.admin.identity }}" | ||
CORE_PEER_LOCALMSPID: "{{ member.msp.id }}" | ||
CORE_PEER_TLS_ENABLED: "{{ 'true' if peer.tls.enabled else 'false' }}" | ||
CORE_PEER_TLS_ROOTCERT_FILE: "{{ ibp[peer.id].pem if ibp[peer.id].pem is defined }}" | ||
changed_when: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
- name: Install contract on all members peers in the channel | ||
include_tasks: install-contract.yml | ||
|
||
- name: Calculate sequence number | ||
include_tasks: calculate-sequence-number.yml | ||
|
||
- name: Approve contract for all members in the channel | ||
include_tasks: approve-contract.yml | ||
|
||
- name: Commit contract in the channel | ||
include_tasks: commit-contract.yml | ||
when: new_sequence_number_reqd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
gateways | ||
nodes | ||
wallets | ||
!**/.gitkeep | ||
service-creds.json |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters