mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-02-23 15:04:39 +01:00
make use of cache
This commit is contained in:
@@ -50,6 +50,10 @@ public class RatingService {
|
||||
.withExpiry(EXPIRY)
|
||||
.withRefresh(REFRESH)
|
||||
.build(this::getRatingForChannelWithoutCache);
|
||||
private final LoadingCache<Pubkey, Set<ChannelId>> getEligibleChannelsCache = new CacheBuilder()
|
||||
.withExpiry(EXPIRY)
|
||||
.withRefresh(REFRESH)
|
||||
.build(this::getEligibleChannelsWithoutCache);
|
||||
|
||||
public RatingService(
|
||||
ChannelService channelService,
|
||||
@@ -107,6 +111,10 @@ public class RatingService {
|
||||
}
|
||||
|
||||
private Set<ChannelId> getEligibleChannels(Pubkey peer) {
|
||||
return getEligibleChannelsCache.get(peer);
|
||||
}
|
||||
|
||||
private Set<ChannelId> getEligibleChannelsWithoutCache(Pubkey peer) {
|
||||
Set<LocalOpenChannel> openChannels = channelService.getOpenChannelsWith(peer);
|
||||
Set<ChannelId> result = new LinkedHashSet<>(openChannels.stream().map(Channel::getId).toList());
|
||||
if (openChannels.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user