fabric-gateway 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -9
- data/lib/fabric/client.rb +13 -5
- data/lib/fabric/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 440a8fa889f826b8b34b4036566bfe969a9daac00f38e5ee3a0898a815a85be5
|
4
|
+
data.tar.gz: bb959422d092506445984a7a1b6370a290febf6c01b1edfaecbfc6e2b82da5f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b44c4324907688d7049a48a018d245812ee3f563ade9707fc52742c41f35f618f05442a1bfe442f1d0efa02be7fc4aca258edee70bbd698b3a4da01683568484
|
7
|
+
data.tar.gz: eea0cfad7d97571c24da1eeec72958bafc737f90c6a9f808a657adb50faca2312a15ce8b227ac8db6385f9fe7a31f01e9e157c999065b8ed95973788dbaf5cdd
|
data/README.md
CHANGED
@@ -22,14 +22,6 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
$ gem install fabric-gateway
|
24
24
|
|
25
|
-
### ISSUES
|
26
|
-
|
27
|
-
Note, there is an issue with the grpc library for MacOS (https://github.com/grpc/grpc/issues/28271). It results in a segfault in ruby when trying to make a connection.
|
28
|
-
|
29
|
-
Workaround: Either run on linux or use a docker container as a workaround.
|
30
|
-
|
31
|
-
Will update to new version of grpc when fix is released.
|
32
|
-
|
33
25
|
## Usage
|
34
26
|
|
35
27
|
This is a beta stage library with all the main hyperledger gateway calls implemented. Although this library has good unit test coverage, it is fairly new and has not yet been run in production environments. The library will be updated to 1.0.0 when the library has proven to be stable.
|
@@ -56,7 +48,7 @@ client_opts = {
|
|
56
48
|
GRPC::Core::Channel::SSL_TARGET => 'peer0.org1.example.com'
|
57
49
|
}
|
58
50
|
}
|
59
|
-
# optional, if you want to set
|
51
|
+
# optional, if you want to set an absolute deadline for each of the individual calls (in seconds)
|
60
52
|
default_call_options = {
|
61
53
|
endorse_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(5) },
|
62
54
|
evaluate_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(5) },
|
@@ -64,6 +56,16 @@ default_call_options = {
|
|
64
56
|
commit_status_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(5) },
|
65
57
|
chaincode_events_options: { deadline: GRPC::Core::TimeConsts.from_relative_time(60) }
|
66
58
|
}
|
59
|
+
|
60
|
+
# for a relative time from when the call is made, pass an integer instead of a GRPC::Core::TimeConsts (still in seconds)
|
61
|
+
default_call_options = {
|
62
|
+
endorse_options: { deadline: 5 },
|
63
|
+
evaluate_options: { deadline: 5 },
|
64
|
+
submit_options: { deadline: 5 },
|
65
|
+
commit_status_options: { deadline: 5 },
|
66
|
+
chaincode_events_options: { deadline: 60 }
|
67
|
+
}
|
68
|
+
|
67
69
|
creds = GRPC::Core::ChannelCredentials.new(load_certs[0])
|
68
70
|
client=Fabric::Client.new(host: 'localhost:7051', creds: creds, default_call_options: default_call_options, **client_opts)
|
69
71
|
|
data/lib/fabric/client.rb
CHANGED
@@ -60,7 +60,7 @@ module Fabric
|
|
60
60
|
# @return [Gateway::EvaluateResponse] evaluate_response
|
61
61
|
#
|
62
62
|
def evaluate(evaluate_request, options = {})
|
63
|
-
@grpc_client.evaluate(evaluate_request,
|
63
|
+
@grpc_client.evaluate(evaluate_request, final_call_options(:evaluate, options))
|
64
64
|
end
|
65
65
|
|
66
66
|
#
|
@@ -72,7 +72,7 @@ module Fabric
|
|
72
72
|
# @return [Gateway::EndorseResponse] endorse_response
|
73
73
|
#
|
74
74
|
def endorse(endorse_request, options = {})
|
75
|
-
@grpc_client.endorse(endorse_request,
|
75
|
+
@grpc_client.endorse(endorse_request, final_call_options(:endorse, options))
|
76
76
|
end
|
77
77
|
|
78
78
|
#
|
@@ -84,7 +84,7 @@ module Fabric
|
|
84
84
|
# @return [Gateway::SubmitResponse] submit_response
|
85
85
|
#
|
86
86
|
def submit(submit_request, options = {})
|
87
|
-
@grpc_client.submit(submit_request,
|
87
|
+
@grpc_client.submit(submit_request, final_call_options(:submit, options))
|
88
88
|
end
|
89
89
|
|
90
90
|
#
|
@@ -97,7 +97,7 @@ module Fabric
|
|
97
97
|
# @return [Gateway::CommitStatusResponse] commit_status_response
|
98
98
|
#
|
99
99
|
def commit_status(commit_status_request, options = {})
|
100
|
-
@grpc_client.commit_status(commit_status_request,
|
100
|
+
@grpc_client.commit_status(commit_status_request, final_call_options(:commit_status, options))
|
101
101
|
end
|
102
102
|
|
103
103
|
#
|
@@ -164,7 +164,7 @@ module Fabric
|
|
164
164
|
#
|
165
165
|
def chaincode_events(chaincode_events_request, options = {}, &block)
|
166
166
|
@grpc_client.chaincode_events(chaincode_events_request,
|
167
|
-
|
167
|
+
final_call_options(:chaincode_events, options), &block)
|
168
168
|
end
|
169
169
|
|
170
170
|
private
|
@@ -195,5 +195,13 @@ module Fabric
|
|
195
195
|
@default_call_options[:commit_status_options] ||= {}
|
196
196
|
@default_call_options[:chaincode_events_options] ||= {}
|
197
197
|
end
|
198
|
+
|
199
|
+
def final_call_options(call_type, call_options)
|
200
|
+
options = @default_call_options["#{call_type}_options".to_sym].merge(call_options || {})
|
201
|
+
if (deadline = options[:deadline]) && !(deadline.is_a? Time)
|
202
|
+
options[:deadline] = GRPC::Core::TimeConsts.from_relative_time(deadline)
|
203
|
+
end
|
204
|
+
options
|
205
|
+
end
|
198
206
|
end
|
199
207
|
end
|
data/lib/fabric/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fabric-gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Chan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05
|
11
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|