From 0277c02b101e47088c634e9450467a59658109bd Mon Sep 17 00:00:00 2001 From: skynetcap <100323448+skynetcap@users.noreply.github.com> Date: Sun, 31 Jul 2022 13:55:55 -0700 Subject: [PATCH] [SRM-124] Fix token symbol permalinking --- .../mmorrell/serumdata/controller/IndexController.java | 8 ++++++-- .../com/mmorrell/serumdata/manager/MarketManager.java | 5 +++++ .../com/mmorrell/serumdata/manager/MarketRankManager.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/mmorrell/serumdata/controller/IndexController.java b/src/main/java/com/mmorrell/serumdata/controller/IndexController.java index cd588fc..b6b0f7c 100644 --- a/src/main/java/com/mmorrell/serumdata/controller/IndexController.java +++ b/src/main/java/com/mmorrell/serumdata/controller/IndexController.java @@ -127,8 +127,12 @@ public String market(Model model, @PathVariable String market) { for (Token baseToken : possibleBaseTokens) { // compile list of markets, return one with most fees accrued. Optional optionalMarket = marketRankManager.getMostActiveMarket(baseToken.getPublicKey()); - optionalMarket.ifPresent(activeMarkets::add); - + if (optionalMarket.isPresent()) { + Market foundMarket = optionalMarket.get(); + if (foundMarket.getBaseMint().equals(baseToken.getPublicKey())) { + activeMarkets.add(foundMarket); + } + } } activeMarkets.sort(Comparator.comparingLong(Market::getQuoteFeesAccrued).reversed()); diff --git a/src/main/java/com/mmorrell/serumdata/manager/MarketManager.java b/src/main/java/com/mmorrell/serumdata/manager/MarketManager.java index bb9ee44..b019509 100644 --- a/src/main/java/com/mmorrell/serumdata/manager/MarketManager.java +++ b/src/main/java/com/mmorrell/serumdata/manager/MarketManager.java @@ -171,6 +171,11 @@ public List getMarketCache() { return new ArrayList<>(marketCache.values()); } + public List getMarketsByBaseMint(PublicKey tokenMint) { + final Set result = new HashSet<>(marketMapCache.getOrDefault(tokenMint, new ArrayList<>())); + return new ArrayList<>(result); + } + public List getMarketsByTokenMint(PublicKey tokenMint) { final Set result = new HashSet<>(); diff --git a/src/main/java/com/mmorrell/serumdata/manager/MarketRankManager.java b/src/main/java/com/mmorrell/serumdata/manager/MarketRankManager.java index 0ef0a38..da8a4b2 100644 --- a/src/main/java/com/mmorrell/serumdata/manager/MarketRankManager.java +++ b/src/main/java/com/mmorrell/serumdata/manager/MarketRankManager.java @@ -85,7 +85,7 @@ public String getImage(String tokenMint) { } public Optional getMostActiveMarket(PublicKey baseMint) { - List markets = marketManager.getMarketsByTokenMint(baseMint); + List markets = marketManager.getMarketsByBaseMint(baseMint); if (markets.size() < 1) { return Optional.empty(); }