Skip to content

Commit

Permalink
Update application endpoint and error handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skynetcap committed Jan 17, 2024
1 parent c4c8b2f commit d9b9c10
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
58 changes: 33 additions & 25 deletions src/main/java/markets/arcana/obcranker/ObCrankerApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,49 @@ public void crankEventHeapLoop() {
Account finalTradingAccount = tradingAccount;

scheduler.scheduleAtFixedRate(() -> {
// SOL/USDC
PublicKey marketId = PublicKey.valueOf("C3YPL3kYCSYKsmHcHrPWx1632GUXGqi2yMXJbfeCc57q");
Optional<String> 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<String> 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<String> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d9b9c10

Please sign in to comment.