Skip to content

Commit

Permalink
feat: save live_cell_changes to block
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Dec 25, 2019
1 parent 60ca753 commit 76f3efc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/ckb_sync/node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def process_block(node_block)

ckb_transactions = build_ckb_transactions(local_block, node_block.transactions, outputs, new_dao_depositor_events)
local_block.ckb_transactions_count = ckb_transactions.size
local_block.live_cell_changes = ckb_transactions.sum(&:live_cell_changes)
CkbTransaction.import!(ckb_transactions, recursive: true, batch_size: 3500, validate: false)
input_capacities = ckb_transactions.reject(&:is_cellbase).pluck(:id).to_h { |id| [id, []] }
update_tx_fee_related_data(local_block, input_capacities)
Expand Down
3 changes: 3 additions & 0 deletions app/serializers/block_list_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ class BlockListSerializer
attribute :transactions_count do |object|
object.ckb_transactions_count.to_s
end
attribute :live_cell_changes do |object|
object.live_cell_changes.to_s
end
end
2 changes: 1 addition & 1 deletion test/controllers/api/v1/blocks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BlocksControllerTest < ActionDispatch::IntegrationTest
valid_get api_v1_blocks_url

response_block = json["data"].first
assert_equal %w(number transactions_count reward miner_hash timestamp ).sort, response_block["attributes"].keys.sort
assert_equal %w(number transactions_count reward miner_hash timestamp live_cell_changes).sort, response_block["attributes"].keys.sort
end

test "should return error object when page param is invalid" do
Expand Down

0 comments on commit 76f3efc

Please sign in to comment.