From d9b9c1022ed744b5c5d5af70c5d48e58826c5aff Mon Sep 17 00:00:00 2001 From: skynetcap <100323448+skynetcap@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:39:54 -0800 Subject: [PATCH] Update application endpoint and error handling Updated the application endpoint value in 'application.properties' file and improved error handling in 'ObCrankerApplication.java'. The error handling enhancement now catches exceptions in the scheduled tasks which will help in identifying and fixing issues in the cranking process. --- .../obcranker/ObCrankerApplication.java | 58 +++++++++++-------- src/main/resources/application.properties | 2 +- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java b/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java index e3c4ec6..d693e35 100644 --- a/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java +++ b/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java @@ -50,41 +50,49 @@ public void crankEventHeapLoop() { Account finalTradingAccount = tradingAccount; scheduler.scheduleAtFixedRate(() -> { - // SOL/USDC - PublicKey marketId = PublicKey.valueOf("C3YPL3kYCSYKsmHcHrPWx1632GUXGqi2yMXJbfeCc57q"); - Optional transactionId = manager.consumeEvents( - finalTradingAccount, - marketId, - 8 - ); - - if (transactionId.isPresent()) { - log.info("Cranked events: {}", transactionId.get()); - } else { - log.info("No events found to consume."); - } - - }, 0, 5, TimeUnit.SECONDS); - - scheduler.scheduleAtFixedRate(() -> { - manager.cacheMarkets(); - for (OpenBookMarket market : manager.getOpenBookMarkets()) { + try { + // SOL/USDC + PublicKey marketId = PublicKey.valueOf("CFSMrBssNG8Ud1edW59jNLnq2cwrQ9uY5cM3wXmqRJj3"); Optional transactionId = manager.consumeEvents( finalTradingAccount, - market.getMarketId(), + marketId, 8 ); if (transactionId.isPresent()) { - log.info("Cranked events [{}]: {}", market.getName(), transactionId.get()); + log.info("Cranked events: {}", transactionId.get()); } else { log.info("No events found to consume."); } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - log.error("Error consuming: {}", e.getMessage()); + } catch (Exception ex) { + log.error("Error cranking SOL/USDC: {}", ex.getMessage(), ex); + } + + }, 0, 5, TimeUnit.SECONDS); + + scheduler.scheduleAtFixedRate(() -> { + try { + manager.cacheMarkets(); + for (OpenBookMarket market : manager.getOpenBookMarkets()) { + Optional transactionId = manager.consumeEvents( + finalTradingAccount, + market.getMarketId(), + 8 + ); + + if (transactionId.isPresent()) { + log.info("Cranked events [{}]: {}", market.getName(), transactionId.get()); + } else { + log.info("No events found to consume."); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + log.error("Error consuming: {}", e.getMessage()); + } } + } catch (Exception ex) { + log.error("Error caching/cranking markets: {}", ex.getMessage(), ex); } }, 0, 60, TimeUnit.SECONDS); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f88ed2e..2b65b66 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,2 @@ -application.endpoint=https://mainnet.helius-rpc.com/?api-key=a778b653-bdd6-41bc-8cda-0c7377faf1dd +application.endpoint=RPC application.privateKey=privateKey.json \ No newline at end of file