Skip to content

Commit

Permalink
fix: get cell_output data from cell_datum
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
  • Loading branch information
zmcNotafraid committed Jul 15, 2024
1 parent 1295066 commit 52dbeba
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/workers/generate_statistics_data_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def perform(block_id)
epoch_stats.update(largest_block_size: block_size, largest_block_number: block.number)
end

cell_outputs = block.cell_outputs.select(:id, :created_at, :data, :capacity, :lock_script_id, :type_script_id).to_a
cell_outputs = block.cell_outputs.includes(:cell_datum)
cell_outputs_attributes = []
cell_outputs.each do |cell_output|
data_size =
if cell_output.data
if cell_output.data != "0x"
CKB::Utils.hex_to_bin(cell_output.data).bytesize
else
0
Expand All @@ -29,11 +29,9 @@ def perform(block_id)
id: cell_output.id,
data_size:,
occupied_capacity: CkbUtils.calculate_cell_min_capacity(cell_output.node_output, cell_output.data),
created_at: cell_output.created_at,
updated_at: Time.current,
}
end

CellOutput.upsert_all(cell_outputs_attributes) if cell_outputs_attributes.present?
CellOutput.upsert_all(cell_outputs_attributes, record_timestamps: true) if cell_outputs_attributes.present?
end
end

0 comments on commit 52dbeba

Please sign in to comment.