From f342a50a7632108248b2e9b30da951b0d553b6c3 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Fri, 15 May 2020 11:43:30 -0600 Subject: [PATCH] Don't discard transaction record when blockhash not found (#10058) * Don't discard transaction records Not enough certainty, because only half the blockhashes are returned via the RPC call. Even if all 300, there's still the possiblity other validators are behind, and a superamajority will vote on on a block that includes the transaction. * fmt --- tokens/src/db.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tokens/src/db.rs b/tokens/src/db.rs index 66f96a8423..1dde747205 100644 --- a/tokens/src/db.rs +++ b/tokens/src/db.rs @@ -127,9 +127,13 @@ pub fn update_finalized_transaction( ) -> Result, Error> { if opt_transaction_status.is_none() { if !recent_blockhashes.contains(blockhash) { - eprintln!("Signature not found {} and blockhash expired", signature); - eprintln!("Discarding transaction record"); - db.rem(&signature.to_string())?; + eprintln!( + "Signature not found {} and blockhash not found, likely expired", + signature + ); + // Don't discard the transaction, because we are not certain the + // blockhash is expired. Instead, return None to signal that + // we don't need to wait for confirmations. return Ok(None); } @@ -245,8 +249,11 @@ mod tests { None ); - // Ensure TransactionInfo has been purged. - assert_eq!(db.get::(&signature.to_string()), None); + // Ensure TransactionInfo has not been purged. + assert_eq!( + db.get::(&signature.to_string()).unwrap(), + transaction_info + ); } #[test]