Skip to content

Commit

Permalink
Merge branch 'nervosnetwork:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz authored Nov 26, 2024
2 parents f39bf44 + 681b2da commit ebd2da3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions app/models/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/)
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions app/models/ckb_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ebd2da3

Please sign in to comment.