@@ -28,19 +28,19 @@ def call
2828 return if target_block_number > tip_block_number - @offset . to_i
2929
3030 target_block = CkbSync ::Api . instance . get_block_by_number ( target_block_number )
31- if !forked? ( target_block , local_tip_block )
31+ if forked? ( target_block , local_tip_block )
32+ self . reorg_started_at = Time . now
33+ res = RevertBlockJob . perform_now ( local_tip_block )
34+ reorg_started_at . delete
35+ res
36+ else
3237 Rails . logger . error "process_block: #{ target_block_number } "
3338 res =
3439 ApplicationRecord . cache do
3540 process_block ( target_block )
3641 end
3742 reorg_started_at . delete
3843 res
39- else
40- self . reorg_started_at = Time . now
41- res = RevertBlockJob . perform_now ( local_tip_block )
42- reorg_started_at . delete
43- res
4444 end
4545 rescue StandardError => e
4646 Rails . logger . error e . message
@@ -418,7 +418,7 @@ def update_or_create_udt_accounts!(local_block)
418418 :symbol , :decimal , :published , :code_hash , :type_hash , :created_at ) . take!
419419 if udt_account . present?
420420 case udt_type
421- when "sudt" , "omiga_inscription" , "xudt" , "xudt_compatible"
421+ when "sudt" , "ssri" , " omiga_inscription", "xudt" , "xudt_compatible"
422422 udt_accounts_attributes << { id : udt_account . id , amount :,
423423 created_at : udt . created_at }
424424 when "m_nft_token" , "nrc_721_token" , "spore_cell" , "did_cell"
@@ -447,7 +447,7 @@ def udt_type(cell_type)
447447
448448 def udt_account_amount ( udt_type , type_hash , address )
449449 case udt_type
450- when "sudt"
450+ when "sudt" , "ssri"
451451 address . cell_outputs . live . udt . where ( type_hash :) . sum ( :udt_amount )
452452 when "xudt" , "xudt_compatible" , "omiga_inscription" , "m_nft_token" , "spore_cell" , "did_cell"
453453 address . cell_outputs . live . where ( cell_type : udt_type ) . where ( type_hash :) . sum ( :udt_amount )
@@ -763,7 +763,7 @@ def build_cells_and_locks!(
763763 build_cell_outputs! ( node_block , outputs , ckb_txs , local_block , cell_outputs_attributes , output_capacities , tags ,
764764 udt_address_ids , contained_udt_ids , contained_addr_ids , addrs_changes , token_transfer_ckb_tx_ids )
765765 if cell_outputs_attributes . present?
766- tx_hashes = cell_outputs_attributes . map { | attr | attr [ :tx_hash ] }
766+ tx_hashes = cell_outputs_attributes . pluck ( :tx_hash )
767767 binary_hashes = CkbUtils . hexes_to_bins_sql ( tx_hashes )
768768 CellOutput . pending . where ( "tx_hash IN (#{ binary_hashes } )" ) . update_all ( status : :live )
769769 id_hashes = CellOutput . upsert_all ( cell_outputs_attributes , unique_by : %i[ tx_hash cell_index status ] ,
@@ -821,7 +821,7 @@ def build_cells_and_locks!(
821821 CellInput . upsert_all ( cell_inputs_attributes ,
822822 unique_by : %i[ ckb_transaction_id index ] )
823823 if prev_cell_outputs_attributes . present?
824- cell_ouput_ids = prev_cell_outputs_attributes . map { | attr | attr [ :id ] }
824+ cell_ouput_ids = prev_cell_outputs_attributes . pluck ( :id )
825825 CellOutput . live . where ( id : cell_ouput_ids ) . update_all ( status : :dead )
826826 CellOutput . upsert_all ( prev_cell_outputs_attributes ,
827827 unique_by : %i[ tx_hash cell_index status ] ,
@@ -962,6 +962,12 @@ def build_cell_inputs(
962962 udt_address_ids [ tx_index ] << address_id
963963 contained_udt_ids [ tx_index ] << Udt . where ( type_hash :,
964964 udt_type : "sudt" ) . pick ( :id )
965+ when "ssri"
966+ tags [ tx_index ] << "ssri"
967+ udt_address_ids [ tx_index ] << address_id
968+ contained_udt_ids [ tx_index ] << Udt . where ( type_hash :,
969+ udt_type : "ssri" ) . pick ( :id )
970+
965971 when "omiga_inscription"
966972 tags [ tx_index ] << "omiga_inscription"
967973 udt_address_ids [ tx_index ] << address_id
@@ -1039,6 +1045,12 @@ def build_cell_outputs!(
10391045 contained_udt_ids [ tx_index ] << Udt . where (
10401046 type_hash : item . type . compute_hash , udt_type : "sudt" ,
10411047 ) . pick ( :id )
1048+ elsif attr [ :cell_type ] == "ssri"
1049+ tags [ tx_index ] << "ssri"
1050+ udt_address_ids [ tx_index ] << address . id
1051+ contained_udt_ids [ tx_index ] << Udt . where (
1052+ type_hash : item . type . compute_hash , udt_type : "ssri" ,
1053+ ) . pick ( :id )
10421054 elsif attr [ :cell_type ] == "omiga_inscription"
10431055 tags [ tx_index ] << "omiga_inscription"
10441056 udt_address_ids [ tx_index ] << address_id
@@ -1068,7 +1080,7 @@ def build_cell_outputs!(
10681080 end
10691081
10701082 def occupied? ( type_hash , cell_data )
1071- cell_data . present? && cell_data != "0x" || type_hash . present?
1083+ ( cell_data . present? && cell_data != "0x" ) || type_hash . present?
10721084 end
10731085
10741086 def cell_output_attributes ( output , address , ckb_transaction , local_block , cell_index , output_data )
0 commit comments