diff --git a/app/models/block.rb b/app/models/block.rb index 18c15c114..2cfddbebc 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -81,7 +81,7 @@ def self.query_transaction_fee_rate(date_string) def self.fetch_transaction_fee_rate_from_cache(date_string) Rails.cache.fetch("transaction_fee_rate_#{date_string}", expires_in: 10.minutes) do - self.query_transaction_fee_rate date_string + query_transaction_fee_rate date_string end end @@ -227,7 +227,7 @@ def block_index_in_epoch end def fraction_epoch - OpenStruct.new(number: epoch, index: block_index_in_epoch, length: length) + OpenStruct.new(number: epoch, index: block_index_in_epoch, length:) end def self.find_block!(query_key) @@ -261,7 +261,7 @@ def self.largest_in_epoch(epoch_number) if b&.block_size { number: b.number, - bytes: b.block_size + bytes: b.block_size, } end end @@ -284,7 +284,8 @@ def cache_keys def invalid! uncle_blocks.delete_all # delete_address_txs_cache - ckb_transactions.destroy_all + ckb_transactions.delete_all + CellOutput.where(block_id: id).delete_all ForkedBlock.create(attributes) destroy end @@ -310,7 +311,7 @@ def self.update_block_median_timestamp(block_number) end def update_counter_for_ckb_node_version - witness = self.cellbase.witnesses[0].data + witness = cellbase.witnesses[0].data return if witness.blank? matched = [witness.gsub("0x", "")].pack("H*").match(/\d\.\d+\.\d/) @@ -325,7 +326,7 @@ def update_counter_for_ckb_node_version # update the current block's ckb_node_version self.ckb_node_version = matched[0] - self.save! + save! end # NOTICE: this method would do a fresh calculate for all the block's ckb_node_version, it will: diff --git a/app/models/ckb_transaction.rb b/app/models/ckb_transaction.rb index a91735da9..5434b8bf9 100644 --- a/app/models/ckb_transaction.rb +++ b/app/models/ckb_transaction.rb @@ -25,8 +25,8 @@ class CkbTransaction < ApplicationRecord has_many :inputs, class_name: "CellOutput", inverse_of: "consumed_by", foreign_key: "consumed_by_id" has_many :outputs, class_name: "CellOutput" has_many :dao_events # , dependent: :delete_all - has_many :script_transactions, dependent: :delete_all - has_many :scripts, through: :script_transactions + # has_many :script_transactions, dependent: :delete_all + # has_many :scripts, through: :script_transactions has_many :referring_cells, dependent: :delete_all has_many :token_transfers, foreign_key: :transaction_id, dependent: :delete_all, inverse_of: :ckb_transaction