Skip to content

Commit

Permalink
Merge pull request #1921 from nervosnetwork/testnet
Browse files Browse the repository at this point in the history
Deploy to mainnet
  • Loading branch information
rabbitz authored Jun 5, 2024
2 parents 1944adc + 652230d commit 0a0c148
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
25 changes: 15 additions & 10 deletions app/jobs/revert_block_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ class RevertBlockJob < ApplicationJob
def perform(local_tip_block = nil)
local_tip_block =
case local_tip_block
when nil
Block.recent.first
when Integer
Block.find(local_tip_block)
else
local_tip_block
when nil
Block.recent.first
when Integer
Block.find(local_tip_block)
else
local_tip_block
end

ApplicationRecord.transaction do
Expand Down Expand Up @@ -79,7 +79,7 @@ def recalculate_udt_transactions_count(local_tip_block)
id: udt_id,
ckb_transactions_count: udt.ckb_transactions_count - count,
created_at: udt.created_at,
updated_at: Time.current
updated_at: Time.current,
}
end

Expand All @@ -101,17 +101,22 @@ def recalculate_udt_accounts(udt_type_hashes, local_tip_block)

local_tip_block.contained_addresses.find_each do |address|
udt_type_hashes.each do |type_hash|
udt_account = address.udt_accounts.find_by(type_hash: type_hash)
udt_account = address.udt_accounts.find_by(type_hash:)
next if udt_account.blank?

case udt_account.udt_type
when "sudt"
amount = address.cell_outputs.live.udt.where(type_hash: type_hash).sum(:udt_amount)
udt_account.update!(amount: amount)
amount = address.cell_outputs.live.udt.where(type_hash:).sum(:udt_amount)
udt_account.update!(amount:)
when "xudt", "omiga_inscription"
amount = address.cell_outputs.live.where(cell_type: udt_account.udt_type).where(type_hash:).sum(:udt_amount)
udt_account.update!(amount:)
when "m_nft_token"
udt_account.destroy
when "nrc_721_token"
udt_account.destroy
when "spore_cell"
udt_account.destroy
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/ckb_transactions/bitcoin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module CkbTransactions
module Bitcoin
extend ActiveSupport::Concern
included do
has_many :bitcoin_vouts
has_many :bitcoin_vins
has_many :bitcoin_transfers
has_one :bitcoin_annotation
has_many :bitcoin_vouts, dependent: :delete_all
has_many :bitcoin_vins, dependent: :delete_all
has_many :bitcoin_transfers, dependent: :delete_all
has_one :bitcoin_annotation, dependent: :delete

delegate :leap_direction, to: :bitcoin_annotation, allow_nil: true
delegate :transfer_step, to: :bitcoin_annotation, allow_nil: true
Expand Down
7 changes: 6 additions & 1 deletion lib/tasks/migration/comprare_output_with_rpc.rake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ namespace :migration do
unless input[:previous_output][:tx_hash] == "0x0000000000000000000000000000000000000000000000000000000000000000"
result = CellOutput.where(tx_hash: input[:previous_output][:tx_hash], cell_index: input[:previous_output][:index].to_i(16), status: :dead).exists?
unless result
$error_ids << r[:header][:number].to_i(16)
output = CellOutput.find_by(tx_hash: input[:previous_output][:tx_hash], cell_index: input[:previous_output][:index].to_i(16), status: :live)
if output.present?
output.update(status: :dead)
else
$error_ids << r[:header][:number].to_i(16)
end
end
end
end
Expand Down

0 comments on commit 0a0c148

Please sign in to comment.