@@ -9,7 +9,8 @@ use engine_core::transaction::TransactionTypeData;
99use serde:: { Deserialize , Serialize } ;
1010use std:: collections:: HashMap ;
1111use std:: ops:: Deref ;
12- use twmq:: redis:: { AsyncCommands , aio:: ConnectionManager } ;
12+ use twmq:: redis:: AsyncCommands ;
13+ use twmq:: redis:: cluster_async:: ClusterConnection ;
1314
1415mod atomic;
1516mod borrowed;
@@ -98,7 +99,7 @@ pub struct TransactionData {
9899
99100/// Transaction store focused on transaction_id operations and nonce indexing
100101pub struct EoaExecutorStore {
101- pub redis : ConnectionManager ,
102+ pub redis : ClusterConnection ,
102103 pub keys : EoaExecutorStoreKeys ,
103104 pub completed_transaction_ttl_seconds : u64 ,
104105}
@@ -121,8 +122,14 @@ impl EoaExecutorStoreKeys {
121122 /// Lock key name for EOA processing
122123 pub fn eoa_lock_key_name ( & self ) -> String {
123124 match & self . namespace {
124- Some ( ns) => format ! ( "{ns}:eoa_executor:lock:{}:{}" , self . chain_id, self . eoa) ,
125- None => format ! ( "eoa_executor:lock:{}:{}" , self . chain_id, self . eoa) ,
125+ Some ( ns) => format ! (
126+ "{ns}:{}:eoa_executor:lock:{}:{}" ,
127+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
128+ ) ,
129+ None => format ! (
130+ "{}:eoa_executor:lock:{}:{}" ,
131+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
132+ ) ,
126133 }
127134 }
128135
@@ -137,8 +144,14 @@ impl EoaExecutorStoreKeys {
137144 /// - "failure_reason": String failure reason (optional)
138145 pub fn transaction_data_key_name ( & self , transaction_id : & str ) -> String {
139146 match & self . namespace {
140- Some ( ns) => format ! ( "{ns}:eoa_executor:tx_data:{transaction_id}" ) ,
141- None => format ! ( "eoa_executor:tx_data:{transaction_id}" ) ,
147+ Some ( ns) => format ! (
148+ "{ns}:{}:eoa_executor:tx_data:{transaction_id}" ,
149+ twmq:: ENGINE_HASH_TAG
150+ ) ,
151+ None => format ! (
152+ "{}:eoa_executor:tx_data:{transaction_id}" ,
153+ twmq:: ENGINE_HASH_TAG
154+ ) ,
142155 }
143156 }
144157
@@ -148,8 +161,14 @@ impl EoaExecutorStoreKeys {
148161 /// of a TransactionAttempt. This allows efficient append operations.
149162 pub fn transaction_attempts_list_name ( & self , transaction_id : & str ) -> String {
150163 match & self . namespace {
151- Some ( ns) => format ! ( "{ns}:eoa_executor:tx_attempts:{transaction_id}" ) ,
152- None => format ! ( "eoa_executor:tx_attempts:{transaction_id}" ) ,
164+ Some ( ns) => format ! (
165+ "{ns}:{}:eoa_executor:tx_attempts:{transaction_id}" ,
166+ twmq:: ENGINE_HASH_TAG
167+ ) ,
168+ None => format ! (
169+ "{}:eoa_executor:tx_attempts:{transaction_id}" ,
170+ twmq:: ENGINE_HASH_TAG
171+ ) ,
153172 }
154173 }
155174
@@ -159,10 +178,13 @@ impl EoaExecutorStoreKeys {
159178 pub fn pending_transactions_zset_name ( & self ) -> String {
160179 match & self . namespace {
161180 Some ( ns) => format ! (
162- "{ns}:eoa_executor:pending_txs:{}:{}" ,
163- self . chain_id, self . eoa
181+ "{ns}:{}:eoa_executor:pending_txs:{}:{}" ,
182+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
183+ ) ,
184+ None => format ! (
185+ "{}:eoa_executor:pending_txs:{}:{}" ,
186+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
164187 ) ,
165- None => format ! ( "eoa_executor:pending_txs:{}:{}" , self . chain_id, self . eoa) ,
166188 }
167189 }
168190
@@ -172,18 +194,27 @@ impl EoaExecutorStoreKeys {
172194 pub fn submitted_transactions_zset_name ( & self ) -> String {
173195 match & self . namespace {
174196 Some ( ns) => format ! (
175- "{ns}:eoa_executor:submitted_txs:{}:{}" ,
176- self . chain_id, self . eoa
197+ "{ns}:{}:eoa_executor:submitted_txs:{}:{}" ,
198+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
199+ ) ,
200+ None => format ! (
201+ "{}:eoa_executor:submitted_txs:{}:{}" ,
202+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
177203 ) ,
178- None => format ! ( "eoa_executor:submitted_txs:{}:{}" , self . chain_id, self . eoa) ,
179204 }
180205 }
181206
182207 /// Name of the key that maps transaction hash to transaction id
183208 pub fn transaction_hash_to_id_key_name ( & self , hash : & str ) -> String {
184209 match & self . namespace {
185- Some ( ns) => format ! ( "{ns}:eoa_executor:tx_hash_to_id:{hash}" ) ,
186- None => format ! ( "eoa_executor:tx_hash_to_id:{hash}" ) ,
210+ Some ( ns) => format ! (
211+ "{ns}:{}:eoa_executor:tx_hash_to_id:{hash}" ,
212+ twmq:: ENGINE_HASH_TAG
213+ ) ,
214+ None => format ! (
215+ "{}:eoa_executor:tx_hash_to_id:{hash}" ,
216+ twmq:: ENGINE_HASH_TAG
217+ ) ,
187218 }
188219 }
189220
@@ -197,10 +228,13 @@ impl EoaExecutorStoreKeys {
197228 pub fn borrowed_transactions_hashmap_name ( & self ) -> String {
198229 match & self . namespace {
199230 Some ( ns) => format ! (
200- "{ns}:eoa_executor:borrowed_txs:{}:{}" ,
201- self . chain_id, self . eoa
231+ "{ns}:{}:eoa_executor:borrowed_txs:{}:{}" ,
232+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
233+ ) ,
234+ None => format ! (
235+ "{}:eoa_executor:borrowed_txs:{}:{}" ,
236+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
202237 ) ,
203- None => format ! ( "eoa_executor:borrowed_txs:{}:{}" , self . chain_id, self . eoa) ,
204238 }
205239 }
206240
@@ -214,12 +248,12 @@ impl EoaExecutorStoreKeys {
214248 pub fn recycled_nonces_zset_name ( & self ) -> String {
215249 match & self . namespace {
216250 Some ( ns) => format ! (
217- "{ns}:eoa_executor:recycled_nonces:{}:{}" ,
218- self . chain_id, self . eoa
251+ "{ns}:{}: eoa_executor:recycled_nonces:{}:{}" ,
252+ twmq :: ENGINE_HASH_TAG , self . chain_id, self . eoa
219253 ) ,
220254 None => format ! (
221- "eoa_executor:recycled_nonces:{}:{}" ,
222- self . chain_id, self . eoa
255+ "{}: eoa_executor:recycled_nonces:{}:{}" ,
256+ twmq :: ENGINE_HASH_TAG , self . chain_id, self . eoa
223257 ) ,
224258 }
225259 }
@@ -236,12 +270,12 @@ impl EoaExecutorStoreKeys {
236270 pub fn optimistic_transaction_count_key_name ( & self ) -> String {
237271 match & self . namespace {
238272 Some ( ns) => format ! (
239- "{ns}:eoa_executor:optimistic_nonce:{}:{}" ,
240- self . chain_id, self . eoa
273+ "{ns}:{}: eoa_executor:optimistic_nonce:{}:{}" ,
274+ twmq :: ENGINE_HASH_TAG , self . chain_id, self . eoa
241275 ) ,
242276 None => format ! (
243- "eoa_executor:optimistic_nonce:{}:{}" ,
244- self . chain_id, self . eoa
277+ "{}: eoa_executor:optimistic_nonce:{}:{}" ,
278+ twmq :: ENGINE_HASH_TAG , self . chain_id, self . eoa
245279 ) ,
246280 }
247281 }
@@ -256,10 +290,13 @@ impl EoaExecutorStoreKeys {
256290 pub fn last_transaction_count_key_name ( & self ) -> String {
257291 match & self . namespace {
258292 Some ( ns) => format ! (
259- "{ns}:eoa_executor:last_tx_nonce:{}:{}" ,
260- self . chain_id, self . eoa
293+ "{ns}:{}:eoa_executor:last_tx_nonce:{}:{}" ,
294+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
295+ ) ,
296+ None => format ! (
297+ "{}:eoa_executor:last_tx_nonce:{}:{}" ,
298+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
261299 ) ,
262- None => format ! ( "eoa_executor:last_tx_nonce:{}:{}" , self . chain_id, self . eoa) ,
263300 }
264301 }
265302
@@ -271,8 +308,14 @@ impl EoaExecutorStoreKeys {
271308 /// - timestamp of the last 5 nonce resets
272309 pub fn eoa_health_key_name ( & self ) -> String {
273310 match & self . namespace {
274- Some ( ns) => format ! ( "{ns}:eoa_executor:health:{}:{}" , self . chain_id, self . eoa) ,
275- None => format ! ( "eoa_executor:health:{}:{}" , self . chain_id, self . eoa) ,
311+ Some ( ns) => format ! (
312+ "{ns}:{}:eoa_executor:health:{}:{}" ,
313+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
314+ ) ,
315+ None => format ! (
316+ "{}:eoa_executor:health:{}:{}" ,
317+ twmq:: ENGINE_HASH_TAG , self . chain_id, self . eoa
318+ ) ,
276319 }
277320 }
278321
@@ -282,20 +325,20 @@ impl EoaExecutorStoreKeys {
282325 pub fn manual_reset_key_name ( & self ) -> String {
283326 match & self . namespace {
284327 Some ( ns) => format ! (
285- "{ns}:eoa_executor:pending_manual_reset:{}:{}" ,
286- self . chain_id, self . eoa
328+ "{ns}:{}: eoa_executor:pending_manual_reset:{}:{}" ,
329+ twmq :: ENGINE_HASH_TAG , self . chain_id, self . eoa
287330 ) ,
288331 None => format ! (
289- "eoa_executor:pending_manual_reset:{}:{}" ,
290- self . chain_id, self . eoa
332+ "{}: eoa_executor:pending_manual_reset:{}:{}" ,
333+ twmq :: ENGINE_HASH_TAG , self . chain_id, self . eoa
291334 ) ,
292335 }
293336 }
294337}
295338
296339impl EoaExecutorStore {
297340 pub fn new (
298- redis : ConnectionManager ,
341+ redis : ClusterConnection ,
299342 namespace : Option < String > ,
300343 eoa : Address ,
301344 chain_id : u64 ,
0 commit comments