Skip to content

Commit

Permalink
Merge pull request #2075 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
zmcNotafraid authored Jul 17, 2024
2 parents 331eab4 + c52d9e4 commit 0416cf3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,9 @@ def build_cells_and_locks!(
build_cell_outputs!(node_block, outputs, ckb_txs, local_block, cell_outputs_attributes, output_capacities, tags,
udt_address_ids, dao_address_ids, contained_udt_ids, contained_addr_ids, addrs_changes, token_transfer_ckb_tx_ids)
if cell_outputs_attributes.present?
tx_ids = cell_outputs_attributes.map { |attr| attr[:ckb_transaction_id] }
CellOutput.pending.where(ckb_transaction_id: tx_ids).update_all(status: :live)
tx_hashes = cell_outputs_attributes.map { |attr| attr[:tx_hash] }
binary_hashes = CkbUtils.hexes_to_bins_sql(tx_hashes)
CellOutput.pending.where("tx_hash IN (#{binary_hashes})").update_all(status: :live)
id_hashes = CellOutput.upsert_all(cell_outputs_attributes, unique_by: %i[tx_hash cell_index status],
returning: %i[id data_hash])
cell_data_attrs = []
Expand Down
8 changes: 5 additions & 3 deletions app/models/daily_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,11 @@ def liquidity
end

define_logic :holder_count do
live_address_ids = CellOutput.live.generated_before(to_be_counted_date.to_i * 1000 - 1).pluck(:address_id)
dead_address_ids = CellOutput.dead.generated_before(to_be_counted_date.to_i * 1000 - 1).consumed_after(to_be_counted_date.to_i * 1000).pluck(:address_id)
(live_address_ids + dead_address_ids).uniq.count
live_query = CellOutput.live.generated_before(to_be_counted_date.to_i * 1000 - 1).select(:address_id).to_sql
dead_query = CellOutput.dead.generated_before(to_be_counted_date.to_i * 1000 - 1).consumed_after(to_be_counted_date.to_i * 1000).select(:address_id).to_sql
combined_query = "#{live_query} UNION #{dead_query}"
count_query = "SELECT COUNT(DISTINCT address_id) AS count FROM (#{combined_query}) AS combined_results;"
ActiveRecord::Base.connection.execute(count_query).first["count"]
end

private
Expand Down

0 comments on commit 0416cf3

Please sign in to comment.