mirror of
				https://github.com/0glabs/0g-storage-node.git
				synced 2025-11-04 00:27:39 +00:00 
			
		
		
		
	copy from middle to previous and afterward tx seqs instead of only from the first seq
This commit is contained in:
		
							parent
							
								
									3ba369e9e5
								
							
						
					
					
						commit
						ff48a05166
					
				@ -273,7 +273,7 @@ impl LogStoreWrite for LogManager {
 | 
				
			|||||||
                bail!("unexpected tx!");
 | 
					                bail!("unexpected tx!");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let maybe_same_data_tx_seq = self.tx_store.put_tx(tx.clone())?.first().cloned();
 | 
					        let same_data_tx_seqs = self.tx_store.put_tx(tx.clone())?;
 | 
				
			||||||
        // TODO(zz): Should we validate received tx?
 | 
					        // TODO(zz): Should we validate received tx?
 | 
				
			||||||
        self.append_subtree_list(
 | 
					        self.append_subtree_list(
 | 
				
			||||||
            tx.seq,
 | 
					            tx.seq,
 | 
				
			||||||
@ -289,9 +289,11 @@ impl LogStoreWrite for LogManager {
 | 
				
			|||||||
        // Drop the lock because `copy_tx_data` will lock again.
 | 
					        // Drop the lock because `copy_tx_data` will lock again.
 | 
				
			||||||
        drop(merkle);
 | 
					        drop(merkle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(old_tx_seq) = maybe_same_data_tx_seq {
 | 
					        for old_tx_seq in same_data_tx_seqs {
 | 
				
			||||||
            if self.check_tx_completed(old_tx_seq)? {
 | 
					            if self.check_tx_completed(old_tx_seq)? {
 | 
				
			||||||
 | 
					                // copy and finalize once, then stop
 | 
				
			||||||
                self.copy_tx_and_finalize(old_tx_seq, vec![tx.seq])?;
 | 
					                self.copy_tx_and_finalize(old_tx_seq, vec![tx.seq])?;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        metrics::PUT_TX.update_since(start_time);
 | 
					        metrics::PUT_TX.update_since(start_time);
 | 
				
			||||||
@ -315,7 +317,7 @@ impl LogStoreWrite for LogManager {
 | 
				
			|||||||
                .get_tx_seq_list_by_data_root(&tx.data_merkle_root)?;
 | 
					                .get_tx_seq_list_by_data_root(&tx.data_merkle_root)?;
 | 
				
			||||||
            // Check if there are other same-root transaction not finalized.
 | 
					            // Check if there are other same-root transaction not finalized.
 | 
				
			||||||
            if same_root_seq_list.first() == Some(&tx_seq) {
 | 
					            if same_root_seq_list.first() == Some(&tx_seq) {
 | 
				
			||||||
                self.copy_tx_and_finalize(tx_seq, same_root_seq_list[1..].to_vec())?;
 | 
					                self.copy_tx_and_finalize(tx_seq, same_root_seq_list)?;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            self.tx_store.finalize_tx(tx_seq)?;
 | 
					            self.tx_store.finalize_tx(tx_seq)?;
 | 
				
			||||||
            Ok(())
 | 
					            Ok(())
 | 
				
			||||||
@ -352,7 +354,7 @@ impl LogStoreWrite for LogManager {
 | 
				
			|||||||
                .get_tx_seq_list_by_data_root(&tx.data_merkle_root)?;
 | 
					                .get_tx_seq_list_by_data_root(&tx.data_merkle_root)?;
 | 
				
			||||||
            // Check if there are other same-root transaction not finalized.
 | 
					            // Check if there are other same-root transaction not finalized.
 | 
				
			||||||
            if same_root_seq_list.first() == Some(&tx_seq) {
 | 
					            if same_root_seq_list.first() == Some(&tx_seq) {
 | 
				
			||||||
                self.copy_tx_and_finalize(tx_seq, same_root_seq_list[1..].to_vec())?;
 | 
					                self.copy_tx_and_finalize(tx_seq, same_root_seq_list)?;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            metrics::FINALIZE_TX_WITH_HASH.update_since(start_time);
 | 
					            metrics::FINALIZE_TX_WITH_HASH.update_since(start_time);
 | 
				
			||||||
            Ok(true)
 | 
					            Ok(true)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user