@@ -8,7 +8,7 @@ class NewNodeDataProcessor
88 include Redis ::Objects
99
1010 value :reorg_started_at , global : true
11- attr_accessor :local_tip_block , :pending_raw_block , :ckb_txs , :target_block , :target_block_number , :addrs_changes ,
11+ attr_accessor :local_tip_block , :pending_raw_block , :ckb_txs , :target_block , :target_block_number ,
1212 :outputs , :inputs , :outputs_data , :udt_address_ids , :contained_address_ids ,
1313 :contained_udt_ids , :cell_datas , :enable_cota , :token_transfer_ckb_tx_ids , :addr_tx_changes , :redis_keys , :tx_previous_outputs
1414
@@ -75,11 +75,10 @@ def process_block(node_block, refresh_balance: true)
7575
7676 benchmark :process_ckb_txs , node_block , ckb_txs , contained_address_ids ,
7777 contained_udt_ids , tags , udt_address_ids
78- @addrs_changes = Hash . new { |hash , key | hash [ key ] = { } }
7978 @addr_tx_changes = Hash . new { |h , k | h [ k ] = Hash . new ( 0 ) }
8079
8180 input_capacities , output_capacities = benchmark :build_cells_and_locks! , local_block , node_block , ckb_txs , inputs , outputs ,
82- tags , udt_address_ids , contained_udt_ids , contained_address_ids , addrs_changes , token_transfer_ckb_tx_ids , cell_deps
81+ tags , udt_address_ids , contained_udt_ids , contained_address_ids , token_transfer_ckb_tx_ids , cell_deps
8382
8483 # update explorer data
8584 benchmark :update_ckb_txs_rel_and_fee , ckb_txs , tags , input_capacities , output_capacities , udt_address_ids ,
@@ -91,7 +90,6 @@ def process_block(node_block, refresh_balance: true)
9190 benchmark :update_or_create_udt_accounts! , local_block
9291 # maybe can be changed to asynchronous update
9392 benchmark :process_dao_events! , local_block
94- # benchmark :update_addresses_info, addrs_changes, local_block, refresh_balance
9593 end
9694
9795 async_update_udt_infos ( local_block )
@@ -732,7 +730,7 @@ def update_ckb_txs_rel_and_fee(
732730
733731 def build_cells_and_locks! (
734732 local_block , node_block , ckb_txs , inputs , outputs , tags , udt_address_ids ,
735- contained_udt_ids , contained_addr_ids , addrs_changes , token_transfer_ckb_tx_ids , cell_deps
733+ contained_udt_ids , contained_addr_ids , token_transfer_ckb_tx_ids , cell_deps
736734 )
737735 cell_outputs_attributes = [ ]
738736 cell_inputs_attributes = [ ]
@@ -755,7 +753,7 @@ def build_cells_and_locks!(
755753 build_addresses! ( outputs , local_block )
756754
757755 build_cell_outputs! ( node_block , outputs , ckb_txs , local_block , cell_outputs_attributes , output_capacities , tags ,
758- udt_address_ids , contained_udt_ids , contained_addr_ids , addrs_changes , token_transfer_ckb_tx_ids )
756+ udt_address_ids , contained_udt_ids , contained_addr_ids , token_transfer_ckb_tx_ids )
759757 if cell_outputs_attributes . present?
760758 tx_hashes = cell_outputs_attributes . pluck ( :tx_hash )
761759 binary_hashes = CkbUtils . hexes_to_bins_sql ( tx_hashes )
@@ -812,7 +810,7 @@ def build_cells_and_locks!(
812810 prev_outputs = nil
813811 build_cell_inputs ( inputs , ckb_txs , local_block . id , cell_inputs_attributes , prev_cell_outputs_attributes ,
814812 input_capacities , tags , udt_address_ids , contained_udt_ids , contained_addr_ids ,
815- prev_outputs , addrs_changes , token_transfer_ckb_tx_ids )
813+ prev_outputs , token_transfer_ckb_tx_ids )
816814
817815 CellInput . import cell_inputs_attributes , validate : false , batch_size : 500
818816 if prev_cell_outputs_attributes . present?
@@ -920,7 +918,7 @@ def script_attributes(script, script_hash)
920918
921919 def build_cell_inputs (
922920 inputs , ckb_txs , local_block_id , cell_inputs_attributes , prev_cell_outputs_attributes ,
923- input_capacities , tags , udt_address_ids , contained_udt_ids , contained_addr_ids , prev_outputs , addrs_changes , token_transfer_ckb_tx_ids
921+ input_capacities , tags , udt_address_ids , contained_udt_ids , contained_addr_ids , prev_outputs , token_transfer_ckb_tx_ids
924922 )
925923 conditions = [ ]
926924
@@ -960,7 +958,6 @@ def build_cell_inputs(
960958 # attributes[2] is previous_cell_output capacity
961959 # attributes[3] is previous_cell_output type_hash
962960 # attributes[4] is previous_cell address_id
963- # attributes[5] is previous_cell data
964961 attributes = cell_input_attributes ( item , ckb_txs [ tx_index ] [ "id" ] ,
965962 local_block_id , prev_outputs , index )
966963 cell_inputs_attributes << attributes [ :cell_input ]
@@ -969,28 +966,13 @@ def build_cell_inputs(
969966 address_id = attributes [ :address_id ]
970967 capacity = attributes [ :capacity ]
971968 type_hash = attributes [ :type_hash ]
972- data = attributes [ :data ]
973- change_rec = addrs_changes [ address_id ]
974-
975969 addr_tx_changes [ tx_index ] [ address_id ] -= capacity
976- change_rec [ :balance_diff ] ||= 0
977- change_rec [ :balance_diff ] -= capacity
978- change_rec [ :balance_occupied_diff ] ||= 0
979- change_rec [ :balance_occupied_diff ] -= capacity if occupied? (
980- type_hash , data
981- )
982- change_rec [ :cells_diff ] ||= 0
983- change_rec [ :cells_diff ] -= 1
984- change_rec [ :ckb_txs ] ||= Set . new
985- change_rec [ :ckb_txs ] << ckb_txs [ tx_index ] [ "tx_hash" ]
986970
987971 prev_cell_outputs_attributes << previous_output
988972 contained_addr_ids [ tx_index ] << address_id
989973 cell_type = previous_output [ :cell_type ] . to_s
990974 if cell_type . in? ( %w( nervos_dao_withdrawing ) )
991975 tags [ tx_index ] << "dao"
992- change_rec [ :dao_txs ] ||= Set . new
993- change_rec [ :dao_txs ] << ckb_txs [ tx_index ] [ "tx_hash" ]
994976 elsif cell_type . in? ( %w( m_nft_token nrc_721_token spore_cell did_cell ) )
995977 token_transfer_ckb_tx_ids << ckb_txs [ tx_index ] [ "id" ]
996978 end
@@ -1038,7 +1020,7 @@ def build_cell_inputs(
10381020
10391021 def build_cell_outputs! (
10401022 node_block , outputs , ckb_txs , local_block , cell_outputs_attributes , output_capacities ,
1041- tags , udt_address_ids , contained_udt_ids , contained_addr_ids , addrs_changes , token_transfer_ckb_tx_ids
1023+ tags , udt_address_ids , contained_udt_ids , contained_addr_ids , token_transfer_ckb_tx_ids
10421024 )
10431025 outputs . each do |tx_index , items |
10441026 cell_index = 0
@@ -1061,24 +1043,9 @@ def build_cell_outputs!(
10611043 @redis_keys << key
10621044 end
10631045 end
1064- cell_data = node_block . transactions [ tx_index ] . outputs_data [ cell_index ]
1065- change_rec = addrs_changes [ address_id ]
1046+
10661047 addr_tx_changes [ tx_index ] [ address_id ] += item . capacity
1067-
1068- change_rec [ :balance_diff ] ||= 0
1069- change_rec [ :balance_diff ] += item . capacity
1070-
1071- change_rec [ :balance_occupied_diff ] ||= 0
10721048 type_script_hash = item . type &.compute_hash
1073- change_rec [ :balance_occupied_diff ] += item . capacity if occupied? (
1074- type_script_hash , cell_data
1075- )
1076-
1077- change_rec [ :cells_diff ] ||= 0
1078- change_rec [ :cells_diff ] += 1
1079-
1080- change_rec [ :ckb_txs ] ||= Set . new
1081- change_rec [ :ckb_txs ] << ckb_txs [ tx_index ] [ "tx_hash" ]
10821049
10831050 contained_addr_ids [ tx_index ] << address_id
10841051 attr = cell_output_attributes ( item , address_id , ckb_txs [ tx_index ] , local_block , cell_index ,
@@ -1087,8 +1054,6 @@ def build_cell_outputs!(
10871054
10881055 if attr [ :cell_type ] . in? ( %w( nervos_dao_deposit nervos_dao_withdrawing ) )
10891056 tags [ tx_index ] << "dao"
1090- change_rec [ :dao_txs ] ||= Set . new
1091- change_rec [ :dao_txs ] << ckb_txs [ tx_index ] [ "tx_hash" ]
10921057 end
10931058
10941059 if attr [ :cell_type ] == "udt"
@@ -1131,10 +1096,6 @@ def build_cell_outputs!(
11311096 end
11321097 end
11331098
1134- def occupied? ( type_hash , cell_data )
1135- ( cell_data . present? && cell_data != "0x" ) || type_hash . present?
1136- end
1137-
11381099 def cell_output_attributes ( output , address_id , ckb_transaction , local_block , cell_index , output_data )
11391100 lock_script_hash = output . lock . compute_hash
11401101 key = "lock_script_hash_#{ lock_script_hash } "
@@ -1246,7 +1207,6 @@ def cell_input_attributes(input, ckb_transaction_id, local_block_id,
12461207 capacity : previous_output . capacity ,
12471208 type_hash : previous_output . type_hash ,
12481209 address_id : previous_output . address_id ,
1249- # data: previous_output.data
12501210 }
12511211 end
12521212 end
0 commit comments