Skip to content

Commit 925321a

Browse files
authored
Merge pull request #2630 from nervosnetwork/testnet
Deploy to mainnet
2 parents 0d9dcd4 + bdb885e commit 925321a

File tree

4 files changed

+1
-49
lines changed

4 files changed

+1
-49
lines changed

app/models/block.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -328,33 +328,10 @@ def update_counter_for_ckb_node_version
328328
return
329329
end
330330

331-
# setup global ckb_node_version
332-
name = "ckb_node_version_#{matched[0]}"
333-
GlobalStatistic.increment(name)
334-
335331
# update the current block's ckb_node_version
336332
self.ckb_node_version = matched[0]
337333
save!
338334
end
339-
340-
# NOTICE: this method would do a fresh calculate for all the block's ckb_node_version, it will:
341-
# 1. delete all the existing ckb_node_version_x.yyy.z
342-
# 2. do a fresh calculate from block number 1 to the latest block at the moment
343-
#
344-
# USAGE:
345-
# ```bash
346-
# $ bundle exec rails runner Block.set_ckb_node_versions_from_miner_message
347-
# ```
348-
#
349-
# @param options [Hash]
350-
def self.set_ckb_node_versions_from_miner_message(options = {})
351-
GlobalStatistic.where("name like ?", "ckb_node_version_%").delete_all
352-
to_block_number = options[:to_block_number] || Block.last.number
353-
# we only need last 100k blocks updated.
354-
Block.last(100000).each do |block|
355-
block.update_counter_for_ckb_node_version
356-
end
357-
end
358335
end
359336

360337
# == Schema Information

app/models/ckb_sync/new_node_data_processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def process_block(node_block, refresh_balance: true)
9797
detect_token_transfer(token_transfer_ckb_tx_ids)
9898
detect_bitcoin_transactions(local_block)
9999

100-
# local_block.update_counter_for_ckb_node_version
100+
local_block.update_counter_for_ckb_node_version
101101
local_block
102102
end
103103

test/controllers/api/v2/blocks_controller_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def setup
2323
witness = Witness.new data: "0x750000000c00000055000000490000001000000030000000310000009bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce801140000007164f48d7a5bf2298166f8d81b81ea4e908e16ad1c000000302e3130332e3020286537373133386520323032322d30342d313129"
2424
Block.any_instance.stubs(:cellbase).returns(cellbase)
2525
CkbTransaction.any_instance.stubs(:witnesses).returns([witness])
26-
27-
Block.set_ckb_node_versions_from_miner_message
2826
end
2927
test "should get ckb_node_versions " do
3028
assert_equal Block.all.size, 4

test/models/block_test.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -286,29 +286,6 @@ class BlockTest < ActiveSupport::TestCase
286286
assert_equal result_last_7_days_ckb_node_version, result_sql
287287
end
288288

289-
test "it should update_counter_for_ckb_node_version" do
290-
block1 = create(:block, block_hash: "001")
291-
tx = create(:ckb_transaction, is_cellbase: true, block_id: block1.id,
292-
witnesses: ["0x640000000c00000055000000490000001000000030000000310000009bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce801140000004a336470564d07ca7059b7980481c2d59809d6370b000000302e3130342e3120282029"])
293-
294-
block1.update_counter_for_ckb_node_version
295-
296-
assert_equal GlobalStatistic.find_by(name: "ckb_node_version_0.104.1").value, 1
297-
end
298-
299-
test "it should update the block version" do
300-
block2 = create(:block, :with_block_hash)
301-
tx = create(:ckb_transaction, is_cellbase: true, block: block2,
302-
witnesses: ["0x800000000c00000055000000490000001000000030000000310000009bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce80114000000dde7801c073dfb3464c7b1f05b806bb2bbb84e9927000000302e3130332e302028353161383134612d646972747920323032322d30342d3230292000000000"])
303-
block3 = create(:block, :with_block_hash)
304-
tx = create(:ckb_transaction, is_cellbase: true, block: block3,
305-
witnesses: ["0x640000000c00000055000000490000001000000030000000310000009bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce801140000004a336470564d07ca7059b7980481c2d59809d6370b000000302e3130342e3120282029"])
306-
307-
Block.set_ckb_node_versions_from_miner_message
308-
assert_equal GlobalStatistic.find_by(name: "ckb_node_version_0.104.1").value, 1
309-
assert_equal GlobalStatistic.find_by(name: "ckb_node_version_0.103.0").value, 1
310-
end
311-
312289
test "cached_find not always return nil" do
313290
assert_nil Block.cached_find("111111")
314291
create(:block, number: 111111)

0 commit comments

Comments
 (0)