Skip to content

Commit cabfbb9

Browse files
authored
Add legacy Redis string conversion methods for submitted transactions (#33)
- Introduced `to_legacy_redis_string_with_nonce` methods in `SubmittedNoopTransaction`, `SubmittedTransactionHydrated`, and `SubmittedTransactionDehydrated` to support legacy transaction string formatting. - Updated the `CleanSubmittedTransactions` implementation to remove legacy formatted keys when processing transactions. These changes enhance compatibility with legacy systems while maintaining existing functionality.
1 parent 9fafe0a commit cabfbb9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

executors/src/eoa/store/submitted.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ impl SubmittedNoopTransaction {
4848
self.nonce,
4949
)
5050
}
51+
52+
pub fn to_legacy_redis_string_with_nonce(&self) -> SubmittedTransactionStringWithNonce {
53+
(
54+
format!("{}:{}:0", self.transaction_hash, NO_OP_TRANSACTION_ID),
55+
self.nonce,
56+
)
57+
}
5158
}
5259

5360
#[derive(Debug, Clone)]
@@ -84,6 +91,13 @@ impl SubmittedTransactionHydrated {
8491
SubmittedTransactionHydrated::Real(tx) => tx.to_redis_string_with_nonce(),
8592
}
8693
}
94+
95+
pub fn to_legacy_redis_string_with_nonce(&self) -> SubmittedTransactionStringWithNonce {
96+
match self {
97+
SubmittedTransactionHydrated::Noop(tx) => tx.to_legacy_redis_string_with_nonce(),
98+
SubmittedTransactionHydrated::Real(tx) => tx.to_legacy_redis_string_with_nonce(),
99+
}
100+
}
87101
}
88102

89103
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -166,6 +180,16 @@ impl SubmittedTransactionDehydrated {
166180
self.nonce,
167181
)
168182
}
183+
184+
pub fn to_legacy_redis_string_with_nonce(&self) -> SubmittedTransactionStringWithNonce {
185+
(
186+
format!(
187+
"{}:{}:{}",
188+
self.transaction_hash, self.transaction_id, self.queued_at
189+
),
190+
self.nonce,
191+
)
192+
}
169193
}
170194

171195
pub struct CleanSubmittedTransactions<'a> {
@@ -277,6 +301,13 @@ impl SafeRedisTransaction for CleanSubmittedTransactions<'_> {
277301
self.keys.submitted_transactions_zset_name(),
278302
&submitted_tx_redis_string,
279303
);
304+
305+
// Also remove the legacy formmated key if present
306+
pipeline.zrem(
307+
self.keys.submitted_transactions_zset_name(),
308+
tx.to_legacy_redis_string_with_nonce(),
309+
);
310+
280311
pipeline.del(self.keys.transaction_hash_to_id_key_name(tx.hash()));
281312

282313
// Process each unique transaction_id once

0 commit comments

Comments
 (0)