mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-20 14:34:24 +01:00
disable cache
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package de.cotto.lndmanagej.pickhardtpayments;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import de.cotto.lndmanagej.caching.CacheBuilder;
|
||||
import de.cotto.lndmanagej.grpc.GrpcGetInfo;
|
||||
import de.cotto.lndmanagej.grpc.GrpcGraph;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
@@ -21,7 +19,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -37,10 +34,6 @@ public class EdgeComputation {
|
||||
private final NodeService nodeService;
|
||||
private final BalanceService balanceService;
|
||||
private final LiquidityBoundsService liquidityBoundsService;
|
||||
private final LoadingCache<Object, EdgesWithLiquidityInformation> cache = new CacheBuilder()
|
||||
.withExpiry(Duration.ofSeconds(10))
|
||||
.withRefresh(Duration.ofSeconds(5))
|
||||
.build(this::getEdgesWithoutCache);
|
||||
|
||||
public EdgeComputation(
|
||||
GrpcGraph grpcGraph,
|
||||
@@ -59,25 +52,6 @@ public class EdgeComputation {
|
||||
}
|
||||
|
||||
public EdgesWithLiquidityInformation getEdges() {
|
||||
return cache.get("");
|
||||
}
|
||||
|
||||
public EdgeWithLiquidityInformation getEdgeWithLiquidityInformation(Edge edge) {
|
||||
Pubkey ownPubkey = grpcGetInfo.getPubkey();
|
||||
return getEdgeWithLiquidityInformation(edge, ownPubkey);
|
||||
}
|
||||
|
||||
private EdgeWithLiquidityInformation getEdgeWithLiquidityInformation(Edge edge, Pubkey ownPubkey) {
|
||||
Coins knownLiquidity = getKnownLiquidity(edge, ownPubkey).orElse(null);
|
||||
if (knownLiquidity == null) {
|
||||
Coins lowerBound = liquidityBoundsService.getAssumedLiquidityLowerBound(edge.startNode(), edge.endNode());
|
||||
Coins upperBound = getAvailableLiquidityUpperBound(edge, lowerBound);
|
||||
return EdgeWithLiquidityInformation.forLowerAndUpperBound(edge, lowerBound, upperBound);
|
||||
}
|
||||
return EdgeWithLiquidityInformation.forKnownLiquidity(edge, knownLiquidity);
|
||||
}
|
||||
|
||||
private EdgesWithLiquidityInformation getEdgesWithoutCache() {
|
||||
Set<DirectedChannelEdge> channelEdges = grpcGraph.getChannelEdges().orElse(null);
|
||||
if (channelEdges == null) {
|
||||
logger.warn("Unable to get graph");
|
||||
@@ -98,6 +72,21 @@ public class EdgeComputation {
|
||||
return new EdgesWithLiquidityInformation(edgesWithLiquidityInformation);
|
||||
}
|
||||
|
||||
public EdgeWithLiquidityInformation getEdgeWithLiquidityInformation(Edge edge) {
|
||||
Pubkey ownPubkey = grpcGetInfo.getPubkey();
|
||||
return getEdgeWithLiquidityInformation(edge, ownPubkey);
|
||||
}
|
||||
|
||||
private EdgeWithLiquidityInformation getEdgeWithLiquidityInformation(Edge edge, Pubkey ownPubkey) {
|
||||
Coins knownLiquidity = getKnownLiquidity(edge, ownPubkey).orElse(null);
|
||||
if (knownLiquidity == null) {
|
||||
Coins lowerBound = liquidityBoundsService.getAssumedLiquidityLowerBound(edge.startNode(), edge.endNode());
|
||||
Coins upperBound = getAvailableLiquidityUpperBound(edge, lowerBound);
|
||||
return EdgeWithLiquidityInformation.forLowerAndUpperBound(edge, lowerBound, upperBound);
|
||||
}
|
||||
return EdgeWithLiquidityInformation.forKnownLiquidity(edge, knownLiquidity);
|
||||
}
|
||||
|
||||
private boolean shouldIgnore(DirectedChannelEdge channelEdge) {
|
||||
Policy policy = channelEdge.policy();
|
||||
return policy.disabled() || policy.baseFee().isPositive();
|
||||
|
||||
Reference in New Issue
Block a user