From b7db667c6bd7f1ce69f2ad59464ac7abceebf6bd Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 12 Sep 2023 19:05:44 +0530 Subject: [PATCH] Use consensus mechanism for sending L2 txs --- src/libp2p-utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libp2p-utils.ts b/src/libp2p-utils.ts index 4ed15f8..e33759d 100644 --- a/src/libp2p-utils.ts +++ b/src/libp2p-utils.ts @@ -89,6 +89,12 @@ export async function sendMessageToL2 ( }, data: any ): Promise { + // Send tx to L2 only if we are the leader + if (!consensus.isLeader()) { + log('Not a leader, skipped sending L2 tx'); + return; + } + const { kind, message } = data; const contract = new ethers.Contract(contractAddress, PhisherRegistryABI, signer);