bitcoinrb-grpc 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config.yml +4 -0
- data/lib/bitcoin/grpc/oap_service.rb +11 -9
- data/lib/bitcoin/grpc/server.rb +22 -21
- data/lib/bitcoin/grpc/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f7e6f764cbbfd51ed4f6a98ff9f0466bed57257420683babbc400ca0cac4c79
|
4
|
+
data.tar.gz: 2e34dfe009279d0b0e75aa38fa8de9541990280438671010c4aee78e8d117709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21ca38a506f519362795143e2a455a0107c11fca9d6ec7f1755f9ad346da6edd311716bc642af0ff0a1a44f685474edb560d3e58eec5dd2d343ee3a316a6fb0e
|
7
|
+
data.tar.gz: 9531c54501014015b9c2cacf59bd87bf19d796697791a3e930fa0ae13c86f43f4873f8e9c118aa953ef1bd36225554710661f21e202088c0b0d237bb2b61a701
|
data/config.yml
ADDED
@@ -14,15 +14,17 @@ module Bitcoin
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.oae_url
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
@@config ||= load_config
|
18
|
+
@@config['url']
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.load_config
|
22
|
+
file = 'config.yml'
|
23
|
+
yml = YAML.load_file(file)
|
24
|
+
config = yml['open_assets_explorer']
|
25
|
+
raise "config.yml should contain 'open_assets_explorer' section." unless config
|
26
|
+
config
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
28
|
-
end
|
30
|
+
end
|
data/lib/bitcoin/grpc/server.rb
CHANGED
@@ -22,10 +22,10 @@ module Bitcoin
|
|
22
22
|
def watch_tx_confirmed(request, call)
|
23
23
|
logger.info("watch_tx_confirmed: #{request}")
|
24
24
|
utxo_handler << request
|
25
|
-
|
26
|
-
Receiver.spawn(:receiver,
|
27
|
-
ResponseEnum.new(request, channel, WatchTxConfirmedResponseBuilder).each
|
25
|
+
response = []
|
26
|
+
Receiver.spawn(:receiver, request, response, publisher, [Bitcoin::Grpc::EventTxConfirmed])
|
28
27
|
logger.info("watch_tx_confirmed: end")
|
28
|
+
ResponseEnum.new(request, response, WatchTxConfirmedResponseBuilder).each
|
29
29
|
rescue => e
|
30
30
|
logger.info("watch_tx_confirmed: #{e.message}")
|
31
31
|
logger.info("watch_tx_confirmed: #{e.backtrace}")
|
@@ -34,10 +34,10 @@ module Bitcoin
|
|
34
34
|
def watch_utxo(request, call)
|
35
35
|
logger.info("watch_utxo: #{request}")
|
36
36
|
utxo_handler << request
|
37
|
-
|
38
|
-
Receiver.spawn(:receiver,
|
39
|
-
ResponseEnum.new(request, channel, WatchUtxoResponseBuilder).each
|
37
|
+
response = []
|
38
|
+
Receiver.spawn(:receiver, request, response, publisher, [Bitcoin::Grpc::EventUtxoRegistered, Bitcoin::Grpc::EventUtxoSpent])
|
40
39
|
logger.info("watch_utxo: end")
|
40
|
+
ResponseEnum.new(request, response, WatchUtxoResponseBuilder).each
|
41
41
|
rescue => e
|
42
42
|
logger.info("watch_utxo: #{e.message}")
|
43
43
|
logger.info("watch_utxo: #{e.backtrace}")
|
@@ -46,10 +46,10 @@ module Bitcoin
|
|
46
46
|
def watch_token(request, call)
|
47
47
|
logger.info("watch_token: #{request}")
|
48
48
|
utxo_handler << request
|
49
|
-
|
50
|
-
Receiver.spawn(:receiver,
|
51
|
-
ResponseEnum.new(request, channel, WatchTokenResponseBuilder).each
|
49
|
+
response = []
|
50
|
+
Receiver.spawn(:receiver, request, response, publisher, [Bitcoin::Grpc::EventTokenIssued, Bitcoin::Grpc::EventTokenTransfered])
|
52
51
|
logger.info("watch_token: end")
|
52
|
+
ResponseEnum.new(request, response, WatchTokenResponseBuilder).each
|
53
53
|
rescue => e
|
54
54
|
logger.info("watch_token: #{e.message}")
|
55
55
|
logger.info("watch_token: #{e.backtrace}")
|
@@ -92,39 +92,40 @@ module Bitcoin
|
|
92
92
|
class Receiver < Concurrent::Actor::Context
|
93
93
|
include Concurrent::Concern::Logging
|
94
94
|
|
95
|
-
attr_reader :
|
95
|
+
attr_reader :request, :response
|
96
96
|
|
97
|
-
def initialize(
|
98
|
-
@channel = channel
|
97
|
+
def initialize(request, response, publisher, classes)
|
99
98
|
@request = request
|
99
|
+
@response = response
|
100
100
|
classes.each {|c| publisher << [:subscribe, c] }
|
101
101
|
end
|
102
102
|
def on_message(message)
|
103
|
-
log(::Logger::DEBUG, "Receiver#on_message:#{message}")
|
104
103
|
if request.id == message.request_id
|
105
104
|
log(::Logger::DEBUG, "Receiver#on_message:#{message}")
|
106
|
-
|
105
|
+
response << message
|
107
106
|
end
|
108
107
|
end
|
109
108
|
end
|
110
109
|
|
111
110
|
class ResponseEnum
|
112
|
-
attr_reader :req, :
|
111
|
+
attr_reader :req, :response, :wrapper_classs, :logger
|
113
112
|
|
114
|
-
def initialize(req,
|
113
|
+
def initialize(req, response, wrapper_classs)
|
115
114
|
@req = req
|
116
|
-
@
|
115
|
+
@response = response
|
117
116
|
@wrapper_classs = wrapper_classs
|
118
117
|
@logger = Bitcoin::Logger.create(:debug)
|
119
118
|
end
|
120
119
|
|
121
120
|
def each
|
122
|
-
logger.info("ResponseEnum#each")
|
123
121
|
return enum_for(:each) unless block_given?
|
124
122
|
loop do
|
125
|
-
event =
|
126
|
-
|
127
|
-
|
123
|
+
event = response.first
|
124
|
+
if event
|
125
|
+
yield wrapper_classs.build(event.request_id, event)
|
126
|
+
else
|
127
|
+
sleep(1)
|
128
|
+
end
|
128
129
|
end
|
129
130
|
end
|
130
131
|
end
|
data/lib/bitcoin/grpc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitcoinrb-grpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hajime Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- bin/console
|
169
169
|
- bin/setup
|
170
170
|
- bitcoinrb-grpc.gemspec
|
171
|
+
- config.yml
|
171
172
|
- lib/bitcoin/grpc.rb
|
172
173
|
- lib/bitcoin/grpc/grpc_pb.rb
|
173
174
|
- lib/bitcoin/grpc/grpc_services_pb.rb
|