From a68ae20f0421a92c2f83b9c6edee034b78198710 Mon Sep 17 00:00:00 2001 From: noah figueras Date: Thu, 30 Nov 2023 10:33:16 +0100 Subject: [PATCH] delay 40s propose txs + check for closed connection on sse event subscription during connectivityCheck --- src/oracle/oracle.ts | 3 ++- src/oracle/rebalancer.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/oracle/oracle.ts b/src/oracle/oracle.ts index 38f8da6..bf09b6e 100644 --- a/src/oracle/oracle.ts +++ b/src/oracle/oracle.ts @@ -76,7 +76,8 @@ export class Oracle extends Config { async checkConnectivity(logs: boolean) { try { const switched = await this.switchToBackup(logs); - if(switched) { + const isClosed = this.event.readyState == EventSource.CLOSED; + if(switched || isClosed) { this.event.close(); EpochListener(this); } diff --git a/src/oracle/rebalancer.ts b/src/oracle/rebalancer.ts index a61186b..011171d 100644 --- a/src/oracle/rebalancer.ts +++ b/src/oracle/rebalancer.ts @@ -44,7 +44,7 @@ export async function Rebalancer (oracle: Oracle, data: any) { export async function proposeEpoch(epochData: any, oracle: Oracle, priority: number): Promise { try { // Random priority to avoid failed tx - await setTimeout((priority * 30) * 1000); + await setTimeout((priority * 40) * 1000); // Submit vote const contract = oracle.governance;