Skip to content

Commit 7f688a0

Browse files
authored
Merge pull request #2595 from nervosnetwork/testnet
Deploy to mainnet
2 parents db0846b + c2d0ae3 commit 7f688a0

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

app/controllers/api/v2/scripts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ScriptsController < BaseController
77
before_action :set_contracts, excepts: [:index]
88

99
def index
10-
scope = Contract.where(verified: true)
10+
scope = Contract.uniq_verified
1111
if params[:script_type].present?
1212
script_types = params[:script_type].split(",").map(&:strip)
1313
if script_types.include?("lock")

app/models/contract.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Contract < ApplicationRecord
66
belongs_to :contract_cell, class_name: "CellOutput", optional: true
77

88
scope :active, -> { where("addresses_count != 0 and total_referring_cells_capacity != 0 and ckb_transactions_count != 0") }
9-
scope :verified, -> { where(verified: true) }
9+
scope :uniq_verified, -> { where(verified: true, deprecated: false) }
1010
scope :primary, -> { where(is_primary: true) }
1111

1212
enum dep_type: { code: 0, dep_group: 1 }

app/models/lock_script.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def lock_info
6767
tip_epoch = tip_epoch(tip_block)
6868

6969
epoch_number, since_value_index = set_since_epoch_number_and_index(since_value)
70-
block_interval = (epoch_number * 1800 + since_value_index * 1800 / since_value.length) - (tip_epoch.number * 1800 + tip_epoch.index * 1800 / tip_epoch.length)
70+
block_interval = ((epoch_number * 1800) + (since_value_index * 1800 / since_value.length)) - ((tip_epoch.number * 1800) + (tip_epoch.index * 1800 / tip_epoch.length))
7171

7272
if block_interval.negative?
7373
block = Block.where(epoch: since_value.number).order(number: :desc).select(:start_number, :length)[0]
@@ -101,9 +101,9 @@ def calculate_bytesize
101101

102102
def verified_script
103103
if hash_type == "type"
104-
Contract.where(verified: true, type_hash: code_hash)&.first
104+
Contract.uniq_verified.where(type_hash: code_hash)&.first
105105
else
106-
Contract.where(verified: true, data_hash: code_hash)&.first
106+
Contract.uniq_verified.where(data_hash: code_hash)&.first
107107
end
108108
end
109109

app/models/type_script.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def calculate_bytesize
6767

6868
def verified_script
6969
if hash_type == "type"
70-
Contract.where(verified: true, type_hash: code_hash)&.first
70+
Contract.uniq_verified.where(type_hash: code_hash)&.first
7171
else
72-
Contract.where(verified: true, data_hash: code_hash)&.first
72+
Contract.uniq_verified.where(data_hash: code_hash)&.first
7373
end
7474
end
7575
end

app/workers/analyze_contract_from_cell_dependency_worker.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def build_contract_attr(cell_output)
148148
deployed_cell_output_id: cell_output.id,
149149
deployed_block_timestamp: cell_output.block_timestamp,
150150
deployed_args: cell_output.type_script&.args,
151+
deprecated: cell_output.dead?,
151152
}
152153
end
153154

app/workers/contract_statistic_worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ContractStatisticWorker
55
def perform
66
h24_tx_ids = CkbTransaction.h24.pluck(:id)
77
ActiveRecord::Base.connection.execute("SET statement_timeout = 0")
8-
Contract.where(verified: true).find_each do |contract|
8+
Contract.uniq_verified.find_each do |contract|
99
contract_cell_ids = CellDepsOutPoint.list_contract_cell_ids_by_contract([contract.id])
1010
ckb_transactions_count = CellDependency.where(contract_cell_id: contract_cell_ids).select(:ckb_transaction_id).distinct.count
1111
h24_ckb_transactions_count = CellDependency.where(contract_cell_id: contract_cell_ids, ckb_transaction_id: h24_tx_ids).select(:ckb_transaction_id).distinct.count

0 commit comments

Comments
 (0)