Skip to content

Commit

Permalink
chore: early return on calculate tx fee (#337)
Browse files Browse the repository at this point in the history
chore: early return on calculate tx fee
  • Loading branch information
shaojunda authored Aug 9, 2019
2 parents 454fd55 + 8a8f15d commit f9af078
Show file tree
Hide file tree
Showing 2 changed files with 2 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 @@ -300,6 +300,7 @@ def update_address_balance_and_ckb_transactions_count(address)

def calculate_tx_fee(local_block)
ckb_transactions = local_block.ckb_transactions.where(is_cellbase: false)
return if ckb_transactions.blank?

ApplicationRecord.transaction do
ckb_transactions.each(&method(:update_transaction_fee))
Expand Down
2 changes: 1 addition & 1 deletion test/models/ckb_sync/node_data_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class NodeDataProcessorTest < ActiveSupport::TestCase

block = Block.last
cellbase = Cellbase.new(block)
expected_cellbase_display_outputs = block.cellbase.cell_outputs.map { |cell_output| { id: cell_output.id, capacity: cell_output.capacity, address_hash: cell_output.address_hash, target_block_number: cellbase.target_block_number, base_reward: cellbase.base_reward, commit_reward: cellbase.commit_reward, proposal_reward: cellbase.proposal_reward, secondary_reward: cellbase.secondary_reward } }
expected_cellbase_display_outputs = block.cellbase.cell_outputs.order(:id).map { |cell_output| { id: cell_output.id, capacity: cell_output.capacity, address_hash: cell_output.address_hash, target_block_number: cellbase.target_block_number, base_reward: cellbase.base_reward, commit_reward: cellbase.commit_reward, proposal_reward: cellbase.proposal_reward, secondary_reward: cellbase.secondary_reward } }

assert_equal expected_cellbase_display_outputs, block.cellbase.display_outputs
end
Expand Down

0 comments on commit f9af078

Please sign in to comment.