Skip to content

Commit 6ee9de9

Browse files
authored
[ᚬmaster] Rc/v0.4.1 (#401)
[ᚬmaster] Rc/v0.4.1
2 parents 3c0938a + 8d12b64 commit 6ee9de9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+520
-221
lines changed

.rubocop.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ inherit_from:
33
inherit_mode:
44
merge:
55
- Exclude
6-
require: rubocop-performance
6+
require:
7+
- rubocop-performance
8+
- rubocop-rails
79
AllCops:
810
DisplayCopNames: true
911
DisplayStyleGuide: true

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.5.3
1+
2.6.4

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
addons:
1010
postgresql: "10"
1111
rvm:
12-
- 2.5.3
12+
- 2.6.4
1313
env:
1414
global:
1515
- RAILS_ENV=test

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# [](https://github.com/shaojunda/ckb-explorer/compare/v0.4.0...v) (2019-09-16)
2+
3+
4+
### Features
5+
6+
* add consumed_tx_hash and generated_tx_hash to display_output ([80964de](https://github.com/shaojunda/ckb-explorer/commit/80964de))
7+
* add generated_tx_hash to display_inputs ([a8ea5b0](https://github.com/shaojunda/ckb-explorer/commit/a8ea5b0))
8+
* update api doc ([be22e6d](https://github.com/shaojunda/ckb-explorer/commit/be22e6d))
9+
* upgrade to Rails 6.0 ([33d8ff8](https://github.com/shaojunda/ckb-explorer/commit/33d8ff8))
10+
11+
12+
### Performance Improvements
13+
14+
* add cache on display info ([a39f282](https://github.com/shaojunda/ckb-explorer/commit/a39f282))
15+
* cache cell input ([4fbdda6](https://github.com/shaojunda/ckb-explorer/commit/4fbdda6))
16+
* enable parallel testing ([a1a696c](https://github.com/shaojunda/ckb-explorer/commit/a1a696c))
17+
* get ckb transactions sql ([c61676e](https://github.com/shaojunda/ckb-explorer/commit/c61676e))
18+
* handling race condition ([a455538](https://github.com/shaojunda/ckb-explorer/commit/a455538))
19+
* use cache on serializer ([3ed1b4b](https://github.com/shaojunda/ckb-explorer/commit/3ed1b4b))
20+
21+
22+
123
# (2019-09-07)
224

325

Gemfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
source "https://rubygems.org"
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby "2.5.3"
4+
ruby "2.6.4"
55

66
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7-
gem "rails", "~> 5.2.2", ">= 5.2.2.1"
7+
gem "rails", "~> 6.0.0"
88
# Use postgresql as the database for Active Record
99
gem "pg", ">= 0.18", "< 2.0"
1010
# Use Puma as the app server
11-
gem "puma", "~> 3.11"
11+
gem "puma", "~> 4.1.1"
1212
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
1313
# gem 'jbuilder', '~> 2.5'
1414
# Use Redis adapter to run Action Cable in production
@@ -90,6 +90,7 @@ group :development do
9090
gem "spring"
9191
gem "spring-watcher-listen", "~> 2.0.0"
9292
gem "rubocop", require: false
93+
gem "rubocop-rails"
9394
gem "rubocop-performance"
9495
gem "awesome_print"
9596
gem "annotate"

Gemfile.lock

Lines changed: 70 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -24,56 +24,69 @@ GIT
2424
GEM
2525
remote: https://rubygems.org/
2626
specs:
27-
actioncable (5.2.3)
28-
actionpack (= 5.2.3)
27+
actioncable (6.0.0)
28+
actionpack (= 6.0.0)
2929
nio4r (~> 2.0)
3030
websocket-driver (>= 0.6.1)
31-
actionmailer (5.2.3)
32-
actionpack (= 5.2.3)
33-
actionview (= 5.2.3)
34-
activejob (= 5.2.3)
31+
actionmailbox (6.0.0)
32+
actionpack (= 6.0.0)
33+
activejob (= 6.0.0)
34+
activerecord (= 6.0.0)
35+
activestorage (= 6.0.0)
36+
activesupport (= 6.0.0)
37+
mail (>= 2.7.1)
38+
actionmailer (6.0.0)
39+
actionpack (= 6.0.0)
40+
actionview (= 6.0.0)
41+
activejob (= 6.0.0)
3542
mail (~> 2.5, >= 2.5.4)
3643
rails-dom-testing (~> 2.0)
37-
actionpack (5.2.3)
38-
actionview (= 5.2.3)
39-
activesupport (= 5.2.3)
44+
actionpack (6.0.0)
45+
actionview (= 6.0.0)
46+
activesupport (= 6.0.0)
4047
rack (~> 2.0)
4148
rack-test (>= 0.6.3)
4249
rails-dom-testing (~> 2.0)
43-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
44-
actionview (5.2.3)
45-
activesupport (= 5.2.3)
50+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
51+
actiontext (6.0.0)
52+
actionpack (= 6.0.0)
53+
activerecord (= 6.0.0)
54+
activestorage (= 6.0.0)
55+
activesupport (= 6.0.0)
56+
nokogiri (>= 1.8.5)
57+
actionview (6.0.0)
58+
activesupport (= 6.0.0)
4659
builder (~> 3.1)
4760
erubi (~> 1.4)
4861
rails-dom-testing (~> 2.0)
49-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
50-
activejob (5.2.3)
51-
activesupport (= 5.2.3)
62+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
63+
activejob (6.0.0)
64+
activesupport (= 6.0.0)
5265
globalid (>= 0.3.6)
53-
activemodel (5.2.3)
54-
activesupport (= 5.2.3)
55-
activerecord (5.2.3)
56-
activemodel (= 5.2.3)
57-
activesupport (= 5.2.3)
58-
arel (>= 9.0)
66+
activemodel (6.0.0)
67+
activesupport (= 6.0.0)
68+
activerecord (6.0.0)
69+
activemodel (= 6.0.0)
70+
activesupport (= 6.0.0)
5971
activerecord-import (1.0.2)
6072
activerecord (>= 3.2)
61-
activestorage (5.2.3)
62-
actionpack (= 5.2.3)
63-
activerecord (= 5.2.3)
73+
activestorage (6.0.0)
74+
actionpack (= 6.0.0)
75+
activejob (= 6.0.0)
76+
activerecord (= 6.0.0)
6477
marcel (~> 0.3.1)
65-
activesupport (5.2.3)
78+
activesupport (6.0.0)
6679
concurrent-ruby (~> 1.0, >= 1.0.2)
6780
i18n (>= 0.7, < 2)
6881
minitest (~> 5.1)
6982
tzinfo (~> 1.1)
83+
zeitwerk (~> 2.1, >= 2.1.8)
7084
addressable (2.6.0)
7185
public_suffix (>= 2.0.2, < 4.0)
7286
annotate (2.7.5)
7387
activerecord (>= 3.2, < 7.0)
7488
rake (>= 10.4, < 13.0)
7589
ansi (1.5.0)
76-
arel (9.0.0)
7790
ast (2.4.0)
7891
awesome_print (1.8.0)
7992
bitcoin-secp256k1 (0.5.2)
@@ -180,7 +193,7 @@ GEM
180193
rake
181194
mina-multistage (1.0.3)
182195
mina (~> 1.0)
183-
mini_mime (1.0.1)
196+
mini_mime (1.0.2)
184197
mini_portile2 (2.4.0)
185198
minitest (5.11.3)
186199
minitest-reporters (1.3.6)
@@ -194,7 +207,7 @@ GEM
194207
net-http-persistent (3.0.1)
195208
connection_pool (~> 2.2)
196209
newrelic_rpm (6.4.0.356)
197-
nio4r (2.3.1)
210+
nio4r (2.4.0)
198211
nokogiri (1.10.4)
199212
mini_portile2 (~> 2.4.0)
200213
open4 (1.3.4)
@@ -211,7 +224,8 @@ GEM
211224
pry-nav (0.3.0)
212225
pry (>= 0.9.10, < 0.13.0)
213226
public_suffix (3.1.0)
214-
puma (3.12.1)
227+
puma (4.1.1)
228+
nio4r (~> 2.0)
215229
rack (2.0.7)
216230
rack-accept (0.4.5)
217231
rack (>= 0.4)
@@ -220,32 +234,34 @@ GEM
220234
rack
221235
rack-test (1.1.0)
222236
rack (>= 1.0, < 3)
223-
rails (5.2.3)
224-
actioncable (= 5.2.3)
225-
actionmailer (= 5.2.3)
226-
actionpack (= 5.2.3)
227-
actionview (= 5.2.3)
228-
activejob (= 5.2.3)
229-
activemodel (= 5.2.3)
230-
activerecord (= 5.2.3)
231-
activestorage (= 5.2.3)
232-
activesupport (= 5.2.3)
237+
rails (6.0.0)
238+
actioncable (= 6.0.0)
239+
actionmailbox (= 6.0.0)
240+
actionmailer (= 6.0.0)
241+
actionpack (= 6.0.0)
242+
actiontext (= 6.0.0)
243+
actionview (= 6.0.0)
244+
activejob (= 6.0.0)
245+
activemodel (= 6.0.0)
246+
activerecord (= 6.0.0)
247+
activestorage (= 6.0.0)
248+
activesupport (= 6.0.0)
233249
bundler (>= 1.3.0)
234-
railties (= 5.2.3)
250+
railties (= 6.0.0)
235251
sprockets-rails (>= 2.0.0)
236252
rails-dom-testing (2.0.3)
237253
activesupport (>= 4.2.0)
238254
nokogiri (>= 1.6)
239-
rails-html-sanitizer (1.0.4)
255+
rails-html-sanitizer (1.2.0)
240256
loofah (~> 2.2, >= 2.2.2)
241-
railties (5.2.3)
242-
actionpack (= 5.2.3)
243-
activesupport (= 5.2.3)
257+
railties (6.0.0)
258+
actionpack (= 6.0.0)
259+
activesupport (= 6.0.0)
244260
method_source
245261
rake (>= 0.8.7)
246-
thor (>= 0.19.0, < 2.0)
262+
thor (>= 0.20.3, < 2.0)
247263
rainbow (3.0.0)
248-
rake (12.3.2)
264+
rake (12.3.3)
249265
rb-fsevent (0.10.3)
250266
rb-inotify (0.10.0)
251267
ffi (~> 1.0)
@@ -261,6 +277,9 @@ GEM
261277
unicode-display_width (>= 1.4.0, < 1.7)
262278
rubocop-performance (1.3.0)
263279
rubocop (>= 0.68.0)
280+
rubocop-rails (2.0.1)
281+
rack (>= 1.1)
282+
rubocop (>= 0.70.0)
264283
ruby-progressbar (1.10.1)
265284
ruby_dep (1.5.0)
266285
safe_yaml (1.0.5)
@@ -329,6 +348,7 @@ GEM
329348
websocket-driver (0.7.1)
330349
websocket-extensions (>= 0.1.0)
331350
websocket-extensions (0.1.4)
351+
zeitwerk (2.1.9)
332352

333353
PLATFORMS
334354
ruby
@@ -358,12 +378,13 @@ DEPENDENCIES
358378
pg (>= 0.18, < 2.0)
359379
pry
360380
pry-nav
361-
puma (~> 3.11)
381+
puma (~> 4.1.1)
362382
rack-cors
363-
rails (~> 5.2.2, >= 5.2.2.1)
383+
rails (~> 6.0.0)
364384
redis (~> 4.0, >= 4.0.3)
365385
rubocop
366386
rubocop-performance
387+
rubocop-rails
367388
ruby-progressbar
368389
shoulda-context
369390
shoulda-matchers
@@ -379,7 +400,7 @@ DEPENDENCIES
379400
webmock
380401

381402
RUBY VERSION
382-
ruby 2.5.3p105
403+
ruby 2.6.4p104
383404

384405
BUNDLED WITH
385406
2.0.1

app/controllers/api/v1/cell_input_data_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CellInputDataController < ApplicationController
44
before_action :validate_query_params
55

66
def show
7-
cell_input = CellInput.find(params[:id])
7+
cell_input = CellInput.cached_find(params[:id])
88
cell_output = cell_input.find_cell_output!
99

1010
render json: CellOutputDataSerializer.new(cell_output)

app/controllers/api/v1/cell_input_lock_scripts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CellInputLockScriptsController < ApplicationController
44
before_action :validate_query_params
55

66
def show
7-
cell_input = CellInput.find(params[:id])
7+
cell_input = CellInput.cached_find(params[:id])
88
lock_script = cell_input.find_lock_script!
99

1010
render json: LockScriptSerializer.new(lock_script)

app/controllers/api/v1/cell_input_type_scripts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CellInputTypeScriptsController < ApplicationController
44
before_action :validate_query_params
55

66
def show
7-
cell_input = CellInput.find(params[:id])
7+
cell_input = CellInput.cached_find(params[:id])
88
type_script = cell_input.find_type_script!
99

1010
render json: TypeScriptSerializer.new(type_script)

app/models/address.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def self.find_or_create_address(lock_script)
1717
address_hash = CkbUtils.generate_address(lock_script)
1818
lock_hash = lock_script.compute_hash
1919

20-
Rails.cache.fetch(lock_hash, expires_in: 1.day) do
20+
Rails.cache.fetch(lock_hash, expires_in: 1.day, race_condition_ttl: 3.seconds) do
2121
Address.find_or_create_by!(address_hash: address_hash, lock_hash: lock_hash)
2222
end
2323
end
@@ -27,7 +27,7 @@ def self.find_address!(query_key)
2727
end
2828

2929
def self.cached_find(query_key)
30-
Rails.cache.fetch([name, query_key]) do
30+
Rails.cache.fetch([name, query_key], race_condition_ttl: 3.seconds) do
3131
if QueryKeyUtils.valid_hex?(query_key)
3232
find_by(lock_hash: query_key)
3333
else

0 commit comments

Comments
 (0)