meeseeker 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meeseeker/block_follower_job.rb +71 -2
- data/lib/meeseeker/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: ee0984fc73172da1b1186ecaf6efee7301857ef06daa1b140f16cc732e93e97f
|
4
|
+
data.tar.gz: 60c2cad0dc9ddd541323dca737f1a6c017f0dc4b458075c5d2512b960133c863
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d031ecca3a20d7b4c484baa461bbe35a2405c240ee4a2cb0ba45d6342bbba91a884cc55b347fd7db4fcdd987734e6d163bbf29be302127d5cf9674215333b592
|
7
|
+
data.tar.gz: f4824210cb157c65a80fdb217f9ec30dc55e09dde132ebe62db3896a08f7b50d2b21978ce9721d7b60312fd3c629abb7f2755f235b2f239281039b394578b35e
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Meeseeker
|
2
2
|
class BlockFollowerJob
|
3
|
+
MAX_VOP_RETRY = 3
|
4
|
+
|
3
5
|
def perform(options = {})
|
4
6
|
block_api = Steem::BlockApi.new(url: Meeseeker.node_url)
|
5
7
|
redis = Meeseeker.redis
|
@@ -116,12 +118,79 @@ module Meeseeker
|
|
116
118
|
begin
|
117
119
|
stream_options = {url: Meeseeker.node_url, mode: mode}
|
118
120
|
options = options.merge(at_block_num: last_block_num)
|
121
|
+
condenser_api = nil
|
119
122
|
|
120
123
|
Steem::Stream.new(stream_options).tap do |stream|
|
121
124
|
puts "Stream begin: #{stream_options.to_json}; #{options.to_json}"
|
122
125
|
|
123
|
-
|
124
|
-
|
126
|
+
# Prior to v0.0.4, we only streamed operations with stream.operations.
|
127
|
+
|
128
|
+
# After v0.0.5, we stream blocks so that we can get block.timestamp,
|
129
|
+
# to embed it into op values. This should also reduce streaming
|
130
|
+
# overhead since we no longer stream block_headers inder the hood.
|
131
|
+
|
132
|
+
stream.blocks(options) do |block, block_num|
|
133
|
+
block.transactions.each_with_index do |transaction, index|
|
134
|
+
transaction.operations.each do |op|
|
135
|
+
op = op.merge(timestamp: block.timestamp)
|
136
|
+
|
137
|
+
yield op, block.transaction_ids[index], block_num
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
next unless !!Meeseeker.include_virtual
|
142
|
+
|
143
|
+
retries = 0
|
144
|
+
|
145
|
+
# This is where it gets tricky. Virtual ops sometims don't show up
|
146
|
+
# right away, especially if we're streaming on head blocks. In that
|
147
|
+
# situation, we might only need to wait about 1 block. This loop
|
148
|
+
# will likely one execute one iteration, but we have fallback logic
|
149
|
+
# in case there are complications.
|
150
|
+
#
|
151
|
+
# See: https://developers.steem.io/tutorials-recipes/virtual-operations-when-streaming-blockchain-transactions
|
152
|
+
|
153
|
+
loop do
|
154
|
+
condenser_api ||= Steem::CondenserApi.new(url: Meeseeker.node_url)
|
155
|
+
condenser_api.get_ops_in_block(block_num, true) do |vops|
|
156
|
+
redo if vops.nil?
|
157
|
+
|
158
|
+
if vops.empty? && mode != :head
|
159
|
+
# Usually, we just need to slow down to allow virtual ops to
|
160
|
+
# show up after a short delay. Adding this delay doesn't
|
161
|
+
# impact overall performance because steem-ruby will batch
|
162
|
+
# when block streams fall behind.
|
163
|
+
|
164
|
+
if retries < MAX_VOP_RETRY
|
165
|
+
retries = retries + 1
|
166
|
+
condenser_api = nil
|
167
|
+
sleep 3 * retries
|
168
|
+
|
169
|
+
redo
|
170
|
+
end
|
171
|
+
|
172
|
+
puts "Gave up retrying virtual ops lookup on block #{block_num}"
|
173
|
+
|
174
|
+
break
|
175
|
+
end
|
176
|
+
|
177
|
+
if retries > 0
|
178
|
+
puts "Found virtual ops for block #{block_num} aftere #{retries} retrie(s)"
|
179
|
+
end
|
180
|
+
|
181
|
+
vops.each do |vop|
|
182
|
+
normalized_op = Hashie::Mash.new(
|
183
|
+
type: vop.op[0],
|
184
|
+
value: vop.op[1],
|
185
|
+
timestamp: vop.timestamp
|
186
|
+
)
|
187
|
+
|
188
|
+
yield normalized_op, vop.trx_id, vop.block
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
break
|
193
|
+
end
|
125
194
|
end
|
126
195
|
end
|
127
196
|
end
|
data/lib/meeseeker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meeseeker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|