Skip to content

Commit

Permalink
feat: do not update dao contract depositors and total depositors
Browse files Browse the repository at this point in the history
when this depositor already has been recorded
  • Loading branch information
shaojunda committed Oct 10, 2019
1 parent 79a3361 commit b666d48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/ckb_sync/node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def process_block(node_block)
ApplicationRecord.transaction do
ckb_transactions = build_ckb_transactions(local_block, node_block.transactions)
local_block.ckb_transactions_count = ckb_transactions.size
Block.import! [local_block], recursive: true, batch_size: 1000, validate: false
Block.import! [local_block], recursive: true, batch_size: 1000, validate: false, on_duplicate_key_update: [:id]
local_block.reload
end

Expand Down Expand Up @@ -248,7 +248,7 @@ def build_cell_outputs(node_outputs, ckb_transaction, addresses, outputs_data)
dao_contract = DaoContract.find_or_create_by(id: 1)
ckb_transaction.dao_events.build(block: ckb_transaction.block, address_id: address.id, event_type: "deposit_to_dao", value: cell_output.capacity, contract_id: dao_contract.id)
if address.dao_deposit.zero?
ckb_transaction.dao_events.build(block: ckb_transaction.block, address_id: address.id, event_type: "new_dao_depositor", value: 1, contract_id: dao_contract.id)
DaoEvent.find_or_create_by(block: ckb_transaction.block, ckb_transaction: ckb_transaction, address_id: address.id, event_type: "new_dao_depositor", value: 1, contract_id: dao_contract.id)
end
end
build_lock_script(cell_output, output.lock, address)
Expand Down

0 comments on commit b666d48

Please sign in to comment.