meeseeker 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 857cc4efa38d7428ba13457a6ffc3db8cb01aab92a26a3cf052b15698d91ca56
4
- data.tar.gz: 3f6398e6bbad560624fe0b5e331f0cba2b3b207edfa15074627b7f964edd262d
2
+ SHA1:
3
+ metadata.gz: 3204b511fca2e18ee8612eb32cd520edaf8bc72e
4
+ data.tar.gz: 803ab700225d7781a0de824ed1f3221f1dce8033
5
5
  SHA512:
6
- metadata.gz: 6ae2f1bdea39419820d35ce2fedb63ceac5c0c59d61c63ef9f7a01470baea9cc0d784a630996997750ece65fdee78ec5b8deb7b339b2e8343e82db3c38682527
7
- data.tar.gz: 635057da03b642a258436e6d78c0bb2c830ddb475a595c16cfdc80b33b4b92cf58e5782bd4a4cd0b6dd3e85c06f7d137170f2ae6395543086e9070cf595a2cfd
6
+ metadata.gz: '079b763077af4e430b84183e96b2bc683668a89677aa6d90bf4238f8a1533200c1c0c64ffe3e00a2f838ecb1e99e6c12a93f3be9ea4e188b24e501de8cd596cd'
7
+ data.tar.gz: 13cc852acec9b743017e20dc58c6566f9acb0f513a0feb30187536540abe8cd6aacb09707f981adf0f69022b5bdb699211fb76096c6a8ee84d310ea1869ef109
data/README.md CHANGED
@@ -121,7 +121,7 @@ When running `meeseeker sync`, the following channels are available:
121
121
 
122
122
  As mentioned in the first `whatever` example, for ops, [all operation types](https://developers.steem.io/apidefinitions/broadcast-ops) can be subscribed to as channels, including virtual operations, if enabled.
123
123
 
124
- In the second `whatever` example, for `custom_json.id`, if you want to subscribe to the `follow` channel, use `steem:op:custom_json:follow`. Or if you want to subscribe to the `sm_team_reveal` channel, use `steem:op:custom_json:follow`. The `custom_json.id` channels are not enabled by default. To enable it, set the `MEESEEKER_PUBLISH_OP_CUSTOM_ID` to `true` (see example below).
124
+ In the second `whatever` example, for `custom_json.id`, if you want to subscribe to the `follow` channel, use `steem:op:custom_json:follow`. Or if you want to subscribe to the `sm_team_reveal` channel, use `steem:op:custom_json:sm_team_reveal`. The `custom_json.id` channels are not enabled by default. To enable it, set the `MEESEEKER_PUBLISH_OP_CUSTOM_ID` to `true` (see example below).
125
125
 
126
126
  For example, from `redis-cli`, if we wanted to stream block numbers:
127
127
 
data/Rakefile CHANGED
@@ -99,8 +99,11 @@ task :reset, [:chain] => [:check_schema] do |t, args|
99
99
  print 'Dropping keys for set: %s ...' % chain.to_s
100
100
 
101
101
  case chain
102
- when :steem, :all then keys += Meeseeker.redis.keys('steem:*')
103
- when :steem_engine, :all then keys += Meeseeker.redis.keys('steem_engine:*')
102
+ when :steem then keys += Meeseeker.redis.keys('steem:*')
103
+ when :steem_engine then keys += Meeseeker.redis.keys('steem_engine:*')
104
+ when :all
105
+ keys += Meeseeker.redis.keys('steem:*')
106
+ keys += Meeseeker.redis.keys('steem_engine:*')
104
107
  end
105
108
 
106
109
  if keys.any?
@@ -323,12 +326,13 @@ namespace :verify do
323
326
 
324
327
  # If we have all the keys, we should also have all transaction ids.
325
328
  expected_ids = keys.map { |k| k.split(':')[2] }.uniq
329
+ expected_ids -= [Meeseeker::VIRTUAL_TRX_ID]
326
330
  actual_ids = nil
327
331
 
328
332
  agent.block(block_num).tap do |block|
329
333
  raise 'Got empty block result.' if block.nil?
330
334
 
331
- actual_ids = block['transactions'].map{|trx| trx['transactionId'].split('-').first}.uniq
335
+ actual_ids = block['transactions'].map{|trx| trx['transactionId'].to_s.split('-').first}.uniq
332
336
  end
333
337
 
334
338
  # We do an intersection to make sure there's no difference between
@@ -360,6 +364,8 @@ namespace :verify do
360
364
  end
361
365
  end
362
366
  end
367
+
368
+ agent.shutdown
363
369
  end
364
370
 
365
371
  desc 'Verifies Steem Engine sidechain against the mainnet.'
@@ -377,7 +383,7 @@ namespace :verify do
377
383
  block_num = transaction['refSteemBlockNumber']
378
384
 
379
385
  block_trxs[block_num] ||= []
380
- block_trxs[block_num] << transaction['transactionId'].split('-').first
386
+ block_trxs[block_num] << transaction['transactionId'].to_s.split('-').first
381
387
  end
382
388
 
383
389
  puts "Related mainnet blocks: #{block_trxs.keys.size}"
@@ -457,7 +463,6 @@ namespace :verify do
457
463
  schedule_channel = 'steem:witness:schedule'
458
464
  redis_url = ENV.fetch('MEESEEKER_REDIS_URL', 'redis://127.0.0.1:6379/0')
459
465
  subscription = Redis.new(url: redis_url)
460
- ctx = Redis.new(url: redis_url)
461
466
  timeout = (max_blocks).to_i * 3
462
467
 
463
468
  subscribe_mode, subscribe_args = if timeout > 0
@@ -18,7 +18,7 @@ module Meeseeker
18
18
  trx_index += 1
19
19
  else
20
20
  if !!last_key_prefix
21
- n, b, t = last_key_prefix.split(':')
21
+ _, b, t = last_key_prefix.split(':')
22
22
  transaction_payload = {
23
23
  block_num: b.to_i,
24
24
  transaction_id: t,
@@ -129,12 +129,12 @@ module Meeseeker
129
129
  # to embed it into op values. This should also reduce streaming
130
130
  # overhead since we no longer stream block_headers inder the hood.
131
131
 
132
- stream.blocks(options) do |block, block_num|
133
- block.transactions.each_with_index do |transaction, index|
132
+ stream.blocks(options) do |b, n|
133
+ b.transactions.each_with_index do |transaction, index|
134
134
  transaction.operations.each do |op|
135
- op = op.merge(timestamp: block.timestamp)
135
+ op = op.merge(timestamp: b.timestamp)
136
136
 
137
- yield op, block.transaction_ids[index], block_num
137
+ yield op, b.transaction_ids[index], n
138
138
  end
139
139
  end
140
140
 
@@ -152,7 +152,7 @@ module Meeseeker
152
152
 
153
153
  loop do
154
154
  condenser_api ||= Steem::CondenserApi.new(url: Meeseeker.node_url)
155
- condenser_api.get_ops_in_block(block_num, true) do |vops|
155
+ condenser_api.get_ops_in_block(n, true) do |vops|
156
156
  redo if vops.nil?
157
157
 
158
158
  if vops.empty? && mode != :head
@@ -169,13 +169,13 @@ module Meeseeker
169
169
  redo
170
170
  end
171
171
 
172
- puts "Gave up retrying virtual ops lookup on block #{block_num}"
172
+ puts "Gave up retrying virtual ops lookup on block #{n}"
173
173
 
174
174
  break
175
175
  end
176
176
 
177
177
  if retries > 0
178
- puts "Found virtual ops for block #{block_num} aftere #{retries} retrie(s)"
178
+ puts "Found virtual ops for block #{n} aftere #{retries} retrie(s)"
179
179
  end
180
180
 
181
181
  vops.each do |vop|
@@ -1,4 +1,6 @@
1
1
  module Meeseeker::SteemEngine
2
+ MAX_RETRY_INTERVAL = 18.0
3
+
2
4
  class FollowerJob
3
5
  def perform(options = {})
4
6
  redis = Meeseeker.redis
@@ -7,9 +9,12 @@ module Meeseeker::SteemEngine
7
9
  current_block_num = nil
8
10
  block_transactions = []
9
11
 
10
- stream_transactions(options) do |transaction, block|
12
+ stream_transactions(options) do |data, block|
13
+ transaction = data[:transaction]
14
+ virtual = !!data[:virtual]
15
+
11
16
  begin
12
- trx_id = transaction['transactionId'].split('-').first
17
+ trx_id = transaction['transactionId'].to_s.split('-').first
13
18
  block_num = block['blockNumber']
14
19
  current_key_prefix = "steem_engine:#{block_num}:#{trx_id}"
15
20
  contract = transaction['contract']
@@ -19,7 +24,7 @@ module Meeseeker::SteemEngine
19
24
  trx_index += 1
20
25
  else
21
26
  if !!last_key_prefix
22
- n, b, t = last_key_prefix.split(':')
27
+ _, b, t = last_key_prefix.split(':')
23
28
  transaction_payload = {
24
29
  block_num: b.to_i,
25
30
  transaction_id: t,
@@ -27,7 +32,14 @@ module Meeseeker::SteemEngine
27
32
  }
28
33
 
29
34
  block_transactions << trx_id
30
- redis.publish('steem_engine:transaction', transaction_payload.to_json)
35
+
36
+ trx_pub_key = if !!virtual
37
+ 'steem_engine:virtual_transaction'
38
+ else
39
+ 'steem_engine:transaction'
40
+ end
41
+
42
+ redis.publish(trx_pub_key, transaction_payload.to_json)
31
43
  end
32
44
 
33
45
  last_key_prefix = "steem_engine:#{block_num}:#{trx_id}"
@@ -57,10 +69,31 @@ module Meeseeker::SteemEngine
57
69
  end
58
70
  end
59
71
  private
72
+ def agent
73
+ @agent ||= Agent.new
74
+ end
75
+
76
+ def agent_reset
77
+ return if @agent.nil?
78
+
79
+ @agent.shutdown
80
+ @agent = nil
81
+ end
82
+
83
+ def retry_interval
84
+ @retry_interval ||= 0.1
85
+ @retry_interval *= 2
86
+
87
+ [@retry_interval, MAX_RETRY_INTERVAL].min
88
+ end
89
+
90
+ def reset_retry_interval
91
+ @retry_interval = nil
92
+ end
93
+
60
94
  def stream_transactions(options = {}, &block)
61
95
  redis = Meeseeker.redis
62
96
  last_block_num = nil
63
- agent = Agent.new
64
97
  until_block_num = options[:until_block_num].to_i
65
98
 
66
99
  if !!options[:at_block_num]
@@ -96,7 +129,15 @@ module Meeseeker::SteemEngine
96
129
  block_num = last_block_num
97
130
 
98
131
  loop do
99
- block = agent.block(block_num)
132
+ begin
133
+ block = agent.block(block_num)
134
+ reset_retry_interval
135
+ rescue Net::HTTP::Persistent::Error => e
136
+ puts "Retrying: #{e}"
137
+ agent_reset
138
+ sleep retry_interval
139
+ redo
140
+ end
100
141
 
101
142
  if block.nil?
102
143
  sleep 3 # sleep for one mainnet block interval
@@ -106,7 +147,19 @@ module Meeseeker::SteemEngine
106
147
  transactions = block['transactions']
107
148
 
108
149
  transactions.each do |transaction|
109
- yield transaction.merge(timestamp: block['timestamp']), block
150
+ yield({transaction: transaction.merge(timestamp: block['timestamp'])}, block)
151
+ end
152
+
153
+ virtual_transactions = block['virtualTransactions']
154
+
155
+ virtual_transactions.each do |virtual_transaction|
156
+ _, vtrx_in_block = virtual_transaction['transactionId'].split('-')
157
+ virtual_transaction = virtual_transaction.merge(
158
+ timestamp: block['timestamp'],
159
+ 'transactionId' => "#{Meeseeker::VIRTUAL_TRX_ID}-#{vtrx_in_block}"
160
+ )
161
+
162
+ yield({transaction: virtual_transaction, virtual: true}, block)
110
163
  end
111
164
 
112
165
  break if until_block_num != 0 && block_num > until_block_num
@@ -1,4 +1,4 @@
1
1
  module Meeseeker
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  AGENT_ID = "meeseeker/#{VERSION}"
4
4
  end
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.7
4
+ version: 0.0.8
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-04-04 00:00:00.000000000 Z
11
+ date: 2019-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  version: '0'
256
256
  requirements: []
257
257
  rubyforge_project:
258
- rubygems_version: 2.7.7
258
+ rubygems_version: 2.6.14
259
259
  signing_key:
260
260
  specification_version: 4
261
261
  summary: Redis based block follower is an efficient way for multiple apps to stream