Commit b390aaa 1 parent 073f4ff commit b390aaa Copy full SHA for b390aaa
File tree 4 files changed +24
-1
lines changed
services/explorer-api/src
database/controllers/l2Tx
4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ requires:
9
9
- path : ./auth/image.yaml
10
10
- path : ./event-cannon/image.yaml
11
11
- path : ./aztec-listener/image.yaml
12
+ - path : ./ethereum-listener/image.yaml
12
13
deploy :
13
14
kubectl :
14
15
flags :
@@ -26,6 +27,7 @@ manifests:
26
27
- k8s/local/auth/service.yaml
27
28
- k8s/local/event-cannon/deployment.yaml
28
29
- k8s/local/aztec-listener/deployment.yaml
30
+ - k8s/local/ethereum-listener/deployment.yaml
29
31
- k8s/local/aztec-sandbox-node/ingress.yaml
30
32
- k8s/local/aztec-sandbox-node/deployment.yaml
31
33
- k8s/local/aztec-sandbox-node/service.yaml
Original file line number Diff line number Diff line change
1
+ import { ChicmozL2PendingTx } from "@chicmoz-pkg/types" ;
2
+ import { eq } from "drizzle-orm" ;
3
+ import { getDb as db } from "../../../database/index.js" ;
4
+ import { l2Tx } from "../../schema/index.js" ;
5
+
6
+ export const deleteTx = async (
7
+ hash : ChicmozL2PendingTx [ "hash" ]
8
+ ) : Promise < void > => {
9
+ await db ( ) . delete ( l2Tx ) . where ( eq ( l2Tx . hash , hash ) ) . execute ( ) ;
10
+ } ;
Original file line number Diff line number Diff line change @@ -3,13 +3,23 @@ import { chicmozL2PendingTxSchema } from "@chicmoz-pkg/types";
3
3
import { logger } from "../logger.js" ;
4
4
import { storeL2Tx } from "../database/controllers/l2Tx/store.js" ;
5
5
import { handleDuplicateError } from "./utils.js" ;
6
+ import { getTxs } from "../database/controllers/l2Tx/get-tx.js" ;
7
+ import { deleteTx } from "../database/controllers/l2Tx/delete.js" ;
6
8
7
9
export const onPendingTxs = async ( { txs } : PendingTxsEvent ) => {
10
+ const dbTxs = await getTxs ( ) ;
11
+ const staleTxs = dbTxs . filter (
12
+ ( dbTx ) => ! txs . some ( ( tx ) => tx . hash === dbTx . hash )
13
+ ) ;
8
14
for ( const tx of txs ) {
9
15
logger . info ( `🕐 Pending tx: ${ tx . hash } ` ) ;
10
16
const res = chicmozL2PendingTxSchema . parse ( tx ) ;
11
17
await storeL2Tx ( res ) . catch ( ( e ) => {
12
18
handleDuplicateError ( e as Error , `tx ${ res . hash } ` ) ;
13
19
} ) ;
14
20
}
21
+ if ( staleTxs . length > 0 ) {
22
+ logger . info ( `🕐🕐🕐 Stale txs: ${ staleTxs . length } . Deleting...` ) ;
23
+ for ( const tx of staleTxs ) await deleteTx ( tx . hash ) ;
24
+ }
15
25
} ;
Original file line number Diff line number Diff line change 1
1
import * as cache from "./cache/index.js" ;
2
+ import { deleteAllTxs } from "./database/controllers/l2Tx/delete-all-txs.js" ;
2
3
import * as db from "./database/index.js" ;
3
4
import { subscribeHandlers } from "./event-handler/index.js" ;
4
5
import { setComponentInitializing , setComponentUp } from "./health.js" ;
@@ -39,7 +40,7 @@ export const start = async () => {
39
40
ID : mb . ID ,
40
41
init : mb . init ,
41
42
} ) ;
42
- // TODO: clear pending txs DB
43
+ await deleteAllTxs ( ) ; // TODO: perhaps a more specific deleteAllTxs should be created, also some logs could be good.
43
44
setComponentInitializing ( "SUBSCRIPTIONS" ) ;
44
45
await subscribeHandlers ( ) ;
45
46
setComponentUp ( "SUBSCRIPTIONS" ) ;
You can’t perform that action at this time.
0 commit comments