Skip to content

Commit

Permalink
chore: optimize cell_type query
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz committed Jan 18, 2024
1 parent 0919c22 commit 18c355e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions app/utils/ckb_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,26 @@ def self.decode_header_deps(raw_header_deps)
# @param [String] output_data
# @return [String] cell type
def self.cell_type(type_script, output_data)
if (CkbSync::Api.instance.mode == CKB::MODE::TESTNET && type_script&.hash_type == "type") ||
(CkbSync::Api.instance.mode == CKB::MODE::MAINNET && type_script&.hash_type == "data1")
if type_script&.code_hash == CkbSync::Api.instance.xudt_code_hash
str = Kredis.string type_script.compute_hash
unless str.value
if OmigaInscriptionInfo.exists?(udt_hash: type_script.compute_hash)
str.value ="omiga_inscription"
else
str.value = "xudt"
end
end

return str.value
end

if type_script&.code_hash == CkbSync::Api.instance.omiga_inscription_info_code_hash
return "omiga_inscription_info"
end
end

return "normal" unless ([
Settings.dao_code_hash, Settings.dao_type_hash, Settings.sudt_cell_type_hash, Settings.sudt1_cell_type_hash,
CkbSync::Api.instance.issuer_script_code_hash, CkbSync::Api.instance.token_class_script_code_hash,
Expand Down Expand Up @@ -446,14 +466,6 @@ def self.cell_type(type_script, output_data)
"spore_cluster"
when *CkbSync::Api.instance.spore_cell_code_hashes
"spore_cell"
when CkbSync::Api.instance.omiga_inscription_info_code_hash
"omiga_inscription_info"
when CkbSync::Api.instance.xudt_code_hash
if OmigaInscriptionInfo.where(udt_hash: type_script.compute_hash).exists?
"omiga_inscription"
else
"xudt"
end
else
if is_nrc_721_token_cell?(output_data)
"nrc_721_token"
Expand Down

0 comments on commit 18c355e

Please sign in to comment.