Class: Fabric::Network
- Inherits:
-
Object
- Object
- Fabric::Network
- Includes:
- Accessors::Gateway
- Defined in:
- lib/fabric/network.rb
Overview
Network represents a blockchain network, or Fabric channel. The Network can be used to access deployed smart contracts, and to listen for events emitted when blocks are committed to the ledger.
JChan & THowe believe this should be called a Channel, however Hyperledger Fabric has decided upon the terminology network - https://github.com/hyperledger/fabric-gateway/issues/355#issuecomment-997888071
Instance Attribute Summary collapse
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from Accessors::Gateway
Instance Method Summary collapse
-
#chaincode_events(contract, start_block: nil, call_options: {}) {|chaincode_event| ... } ⇒ Enumerator|GRPC::ActiveCall::Operation|nil
Get chaincode events emitted by transaction functions of a specific chaincode.
-
#initialize(gateway, name) ⇒ Network
constructor
A new instance of Network.
-
#new_chaincode_events_request(contract, start_block: nil) ⇒ Fabric::ChaincodeEventsRequest
Create a request to receive chaincode events emitted by transaction functions of a specific chaincode.
-
#new_contract(chaincode_name, contract_name = '') ⇒ Fabric::Contract
Creates a new contract instance.
Constructor Details
#initialize(gateway, name) ⇒ Network
Returns a new instance of Network.
17 18 19 20 |
# File 'lib/fabric/network.rb', line 17 def initialize(gateway, name) @gateway = gateway @name = name end |
Instance Attribute Details
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
12 13 14 |
# File 'lib/fabric/network.rb', line 12 def gateway @gateway end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/fabric/network.rb', line 12 def name @name end |
Instance Method Details
#chaincode_events(contract, start_block: nil, call_options: {}) {|chaincode_event| ... } ⇒ Enumerator|GRPC::ActiveCall::Operation|nil
Get chaincode events emitted by transaction functions of a specific chaincode.
50 51 52 |
# File 'lib/fabric/network.rb', line 50 def chaincode_events(contract, start_block: nil, call_options: {}, &block) new_chaincode_events_request(contract, start_block: start_block).get_events(, &block) end |
#new_chaincode_events_request(contract, start_block: nil) ⇒ Fabric::ChaincodeEventsRequest
Test off-line signing flow.
I'm lying. I just copy and pasted the description from the node SDK. Offline signing should work, but it has not been explicitly tested.
Create a request to receive chaincode events emitted by transaction functions of a specific chaincode. Supports off-line signing flow.
66 67 68 |
# File 'lib/fabric/network.rb', line 66 def new_chaincode_events_request(contract, start_block: nil) ChaincodeEventsRequest.new(contract, start_block: start_block) end |
#new_contract(chaincode_name, contract_name = '') ⇒ Fabric::Contract
Creates a new contract instance
30 31 32 |
# File 'lib/fabric/network.rb', line 30 def new_contract(chaincode_name, contract_name = '') Contract.new(self, chaincode_name, contract_name) end |