Class: Fabric::Client
- Inherits:
-
Object
- Object
- Fabric::Client
- Defined in:
- lib/fabric/client.rb
Instance Attribute Summary collapse
-
#event_hubs ⇒ Object
readonly
Returns the value of attribute event_hubs.
-
#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
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #invoke(request = {}) ⇒ Object
- #query(request = {}) ⇒ Object
- #register_event_hub(options, extra_options = {}) ⇒ Object
- #register_orderer(options, extra_options = {}) ⇒ Object
- #register_peer(options, extra_options = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 |
# File 'lib/fabric/client.rb', line 5 def initialize(opts = {}) = Fabric..merge opts @logger = FabricLogger.new [:logger], [:logger_filters] @identity = [:identity] end |
Instance Attribute Details
#event_hubs ⇒ Object (readonly)
Returns the value of attribute event_hubs.
3 4 5 |
# File 'lib/fabric/client.rb', line 3 def event_hubs @event_hubs end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
3 4 5 |
# File 'lib/fabric/client.rb', line 3 def identity @identity end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/fabric/client.rb', line 3 def logger @logger end |
#orderers ⇒ Object (readonly)
Returns the value of attribute orderers.
3 4 5 |
# File 'lib/fabric/client.rb', line 3 def orderers @orderers end |
#peers ⇒ Object (readonly)
Returns the value of attribute peers.
3 4 5 |
# File 'lib/fabric/client.rb', line 3 def peers @peers end |
Instance Method Details
#invoke(request = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fabric/client.rb', line 50 def invoke(request = {}) logging __method__, request proposal = Proposal.new identity, request responses = send_query(proposal) { |response| parse_peer_response response } transaction = Transaction.new identity, proposal: proposal, responses: responses send_transaction(transaction) { |response| parse_orderer_response response } responses.map { |response| parse_chaincode_response response.response } transaction end |
#query(request = {}) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/fabric/client.rb', line 42 def query(request = {}) logging __method__, request proposal = Proposal.new identity, request send_query(proposal) { |response| parse_chaincode_response response.response } end |
#register_event_hub(options, extra_options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/fabric/client.rb', line 32 def register_event_hub(, = {}) @event_hubs ||= [] = { host: } if .is_a?(String) .merge!() .merge!(logger: logger) @event_hubs << EventHub.new([:host], [:creds], ) end |