Class: Fabric::Channel
- Inherits:
-
Object
- Object
- Fabric::Channel
- Defined in:
- lib/fabric/channel.rb
Instance Attribute Summary collapse
-
#channel_id ⇒ Object
readonly
Returns the value of attribute channel_id.
-
#crypto_suite ⇒ Object
readonly
Returns the value of attribute crypto_suite.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#orderers ⇒ Object
readonly
Returns the value of attribute orderers.
-
#peers ⇒ Object
readonly
Returns the value of attribute peers.
Instance Method Summary collapse
- #create_transaction_info ⇒ Object
-
#initialize(opts = {}) ⇒ Channel
constructor
A new instance of Channel.
- #invoke(chaincode_response) ⇒ Object
- #query(request = {}) ⇒ Object
- #register_orderer(url, opts = {}) ⇒ Object
- #register_peer(url, opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Channel
Returns a new instance of Channel.
6 7 8 9 10 11 12 13 |
# File 'lib/fabric/channel.rb', line 6 def initialize(opts = {}) = Fabric..merge opts @channel_id = [:channel_id] @logger = FabricLogger.new [:logger], [:logger_filters] @identity = [:identity] @crypto_suite = [:crypto_suite] end |
Instance Attribute Details
#channel_id ⇒ Object (readonly)
Returns the value of attribute channel_id.
3 4 5 |
# File 'lib/fabric/channel.rb', line 3 def channel_id @channel_id end |
#crypto_suite ⇒ Object (readonly)
Returns the value of attribute crypto_suite.
3 4 5 |
# File 'lib/fabric/channel.rb', line 3 def crypto_suite @crypto_suite end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
3 4 5 |
# File 'lib/fabric/channel.rb', line 3 def identity @identity end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/fabric/channel.rb', line 3 def logger @logger end |
#orderers ⇒ Object (readonly)
Returns the value of attribute orderers.
3 4 5 |
# File 'lib/fabric/channel.rb', line 3 def orderers @orderers end |
#peers ⇒ Object (readonly)
Returns the value of attribute peers.
3 4 5 |
# File 'lib/fabric/channel.rb', line 3 def peers @peers end |
Instance Method Details
#create_transaction_info ⇒ Object
54 55 56 |
# File 'lib/fabric/channel.rb', line 54 def create_transaction_info TransactionInfo.new crypto_suite, identity end |
#invoke(chaincode_response) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fabric/channel.rb', line 43 def invoke(chaincode_response) transaction = Transaction.new crypto_suite, identity, proposal: chaincode_response.proposal, responses: chaincode_response.proposal_responses send_transaction transaction chaincode_response end |
#query(request = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fabric/channel.rb', line 27 def query(request = {}) request[:channel_id] = channel_id logging __method__, request proposal = Proposal.new crypto_suite, identity, request proposal_responses = peers.map { |peer| peer.send_process_proposal(proposal.signed_proposal) } chaincode_response = ChaincodeResponse.new proposal: proposal, proposal_responses: proposal_responses chaincode_response.validate! chaincode_response end |