From 6cf35d0f86dafb636d77fdc93854fe8f5dc0d16f Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Wed, 20 Nov 2024 18:07:39 +0900 Subject: [PATCH] fix: revert is too slowly Signed-off-by: Miles Zhang --- app/models/block.rb | 10 +++++----- app/models/ckb_transaction.rb | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/block.rb b/app/models/block.rb index 18c15c114..ef5f1d435 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 @@ -310,7 +310,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 +325,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..cf3f04bdf 100644 --- a/app/models/ckb_transaction.rb +++ b/app/models/ckb_transaction.rb @@ -25,12 +25,12 @@ 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 - has_many :cell_dependencies, dependent: :delete_all + # has_many :cell_dependencies, dependent: :delete_all has_many :header_dependencies, dependent: :delete_all has_many :witnesses, dependent: :delete_all