1- // Copyright 2018-2019 Kodebox, Inc.
1+ // Copyright 2018-2020 Kodebox, Inc.
22// This file is part of CodeChain.
33//
44// This program is free software: you can redistribute it and/or modify
@@ -140,11 +140,6 @@ impl BodyDB {
140140 & self ,
141141 best_block_changed : & BestBlockChanged ,
142142 ) -> HashMap < TxHash , Option < TransactionAddress > > {
143- let block_hash = if let Some ( best_block_hash) = best_block_changed. new_best_hash ( ) {
144- best_block_hash
145- } else {
146- return HashMap :: new ( )
147- } ;
148143 let block = match best_block_changed. best_block ( ) {
149144 Some ( block) => block,
150145 None => return HashMap :: new ( ) ,
@@ -155,27 +150,6 @@ impl BodyDB {
155150 BestBlockChanged :: CanonChainAppended {
156151 ..
157152 } => tx_hash_and_address_entries ( best_block_changed. new_best_hash ( ) . unwrap ( ) , tx_hashes) . collect ( ) ,
158- BestBlockChanged :: BranchBecomingCanonChain {
159- tree_route,
160- ..
161- } => {
162- let enacted = tree_route. enacted . iter ( ) . flat_map ( |hash| {
163- let body = self . block_body ( hash) . expect ( "Enacted block must be in database." ) ;
164- let enacted_tx_hashes = body. transaction_hashes ( ) ;
165- tx_hash_and_address_entries ( * hash, enacted_tx_hashes)
166- } ) ;
167-
168- let current_addresses = { tx_hash_and_address_entries ( block_hash, tx_hashes) } ;
169-
170- let retracted = tree_route. retracted . iter ( ) . flat_map ( |hash| {
171- let body = self . block_body ( & hash) . expect ( "Retracted block must be in database." ) ;
172- let retracted_tx_hashes = body. transaction_hashes ( ) . into_iter ( ) ;
173- retracted_tx_hashes. map ( |hash| ( hash, None ) )
174- } ) ;
175-
176- // The order here is important! Don't remove transactions if it was part of enacted blocks as well.
177- retracted. chain ( enacted) . chain ( current_addresses) . collect ( )
178- }
179153 BestBlockChanged :: None => HashMap :: new ( ) ,
180154 }
181155 }
@@ -204,26 +178,6 @@ impl BodyDB {
204178 Box :: new ( :: std:: iter:: empty ( ) ) ,
205179 Box :: new ( tracker_and_addresses_entries ( block_hash, block. transactions ( ) ) ) ,
206180 ) ,
207- BestBlockChanged :: BranchBecomingCanonChain {
208- ref tree_route,
209- ..
210- } => {
211- let enacted = tree_route
212- . enacted
213- . iter ( )
214- . flat_map ( |hash| {
215- let body = self . block_body ( hash) . expect ( "Enacted block must be in database." ) ;
216- tracker_and_addresses_entries ( * hash, body. transactions ( ) )
217- } )
218- . chain ( tracker_and_addresses_entries ( block_hash, block. transactions ( ) ) ) ;
219-
220- let retracted = tree_route. retracted . iter ( ) . flat_map ( |hash| {
221- let body = self . block_body ( hash) . expect ( "Retracted block must be in database." ) ;
222- tracker_and_addresses_entries ( * hash, body. transactions ( ) )
223- } ) ;
224-
225- ( Box :: new ( retracted) , Box :: new ( enacted) )
226- }
227181 BestBlockChanged :: None => return Default :: default ( ) ,
228182 } ;
229183
0 commit comments