relax grpc rate limits for testnet
This commit is contained in:
parent
43a6180cda
commit
df7119a41a
@ -1,5 +1,6 @@
|
|||||||
package haveno.daemon.grpc;
|
package haveno.daemon.grpc;
|
||||||
|
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.common.proto.ProtoUtil;
|
import haveno.common.proto.ProtoUtil;
|
||||||
import haveno.core.api.CoreApi;
|
import haveno.core.api.CoreApi;
|
||||||
import haveno.core.support.dispute.Attachment;
|
import haveno.core.support.dispute.Attachment;
|
||||||
@ -137,11 +138,11 @@ public class GrpcDisputesService extends DisputesImplBase {
|
|||||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||||
new HashMap<>() {{
|
new HashMap<>() {{
|
||||||
put(getGetDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getGetDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 1, SECONDS));
|
||||||
put(getGetDisputesMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getGetDisputesMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 1, SECONDS));
|
||||||
put(getResolveDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getResolveDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 1, SECONDS));
|
||||||
put(getOpenDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getOpenDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 1, SECONDS));
|
||||||
put(getSendDisputeChatMessageMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getSendDisputeChatMessageMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 2, SECONDS));
|
||||||
}}
|
}}
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package haveno.daemon.grpc;
|
package haveno.daemon.grpc;
|
||||||
|
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.core.api.CoreApi;
|
import haveno.core.api.CoreApi;
|
||||||
import haveno.core.api.model.OfferInfo;
|
import haveno.core.api.model.OfferInfo;
|
||||||
import haveno.core.offer.Offer;
|
import haveno.core.offer.Offer;
|
||||||
@ -54,6 +55,7 @@ import static haveno.proto.grpc.OffersGrpc.getGetMyOffersMethod;
|
|||||||
import static haveno.proto.grpc.OffersGrpc.getGetOfferMethod;
|
import static haveno.proto.grpc.OffersGrpc.getGetOfferMethod;
|
||||||
import static haveno.proto.grpc.OffersGrpc.getGetOffersMethod;
|
import static haveno.proto.grpc.OffersGrpc.getGetOffersMethod;
|
||||||
import static haveno.proto.grpc.OffersGrpc.getPostOfferMethod;
|
import static haveno.proto.grpc.OffersGrpc.getPostOfferMethod;
|
||||||
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -201,12 +203,12 @@ class GrpcOffersService extends OffersImplBase {
|
|||||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||||
new HashMap<>() {{
|
new HashMap<>() {{
|
||||||
put(getGetOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getGetOfferMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 1, SECONDS));
|
||||||
put(getGetMyOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getGetMyOfferMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 1, SECONDS));
|
||||||
put(getGetOffersMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getGetOffersMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 1, SECONDS));
|
||||||
put(getGetMyOffersMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getGetMyOffersMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 3, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getPostOfferMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getPostOfferMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 3, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getCancelOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getCancelOfferMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 3, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
}}
|
}}
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package haveno.daemon.grpc;
|
package haveno.daemon.grpc;
|
||||||
|
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.core.api.CoreApi;
|
import haveno.core.api.CoreApi;
|
||||||
import haveno.core.api.model.PaymentAccountForm;
|
import haveno.core.api.model.PaymentAccountForm;
|
||||||
import haveno.core.api.model.PaymentAccountFormField;
|
import haveno.core.api.model.PaymentAccountFormField;
|
||||||
@ -39,6 +40,7 @@ import haveno.proto.grpc.GetPaymentAccountsReply;
|
|||||||
import haveno.proto.grpc.GetPaymentAccountsRequest;
|
import haveno.proto.grpc.GetPaymentAccountsRequest;
|
||||||
import haveno.proto.grpc.GetPaymentMethodsReply;
|
import haveno.proto.grpc.GetPaymentMethodsReply;
|
||||||
import haveno.proto.grpc.GetPaymentMethodsRequest;
|
import haveno.proto.grpc.GetPaymentMethodsRequest;
|
||||||
|
import haveno.proto.grpc.PaymentAccountsGrpc.PaymentAccountsImplBase;
|
||||||
import haveno.proto.grpc.ValidateFormFieldReply;
|
import haveno.proto.grpc.ValidateFormFieldReply;
|
||||||
import haveno.proto.grpc.ValidateFormFieldRequest;
|
import haveno.proto.grpc.ValidateFormFieldRequest;
|
||||||
import io.grpc.ServerInterceptor;
|
import io.grpc.ServerInterceptor;
|
||||||
@ -51,12 +53,12 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||||
import static haveno.proto.grpc.PaymentAccountsGrpc.PaymentAccountsImplBase;
|
|
||||||
import static haveno.proto.grpc.PaymentAccountsGrpc.getCreateCryptoCurrencyPaymentAccountMethod;
|
import static haveno.proto.grpc.PaymentAccountsGrpc.getCreateCryptoCurrencyPaymentAccountMethod;
|
||||||
import static haveno.proto.grpc.PaymentAccountsGrpc.getCreatePaymentAccountMethod;
|
import static haveno.proto.grpc.PaymentAccountsGrpc.getCreatePaymentAccountMethod;
|
||||||
import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentAccountFormMethod;
|
import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentAccountFormMethod;
|
||||||
import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentAccountsMethod;
|
import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentAccountsMethod;
|
||||||
import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentMethodsMethod;
|
import static haveno.proto.grpc.PaymentAccountsGrpc.getGetPaymentMethodsMethod;
|
||||||
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -199,11 +201,11 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase {
|
|||||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||||
new HashMap<>() {{
|
new HashMap<>() {{
|
||||||
put(getCreatePaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS));
|
put(getCreatePaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 100 : 1, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getCreateCryptoCurrencyPaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS));
|
put(getCreateCryptoCurrencyPaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 100 : 1, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getGetPaymentAccountsMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS));
|
put(getGetPaymentAccountsMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 100 : 1, SECONDS));
|
||||||
put(getGetPaymentMethodsMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS));
|
put(getGetPaymentMethodsMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 100 : 1, SECONDS));
|
||||||
put(getGetPaymentAccountFormMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS));
|
put(getGetPaymentAccountFormMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 100 : 1, SECONDS));
|
||||||
}}
|
}}
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package haveno.daemon.grpc;
|
package haveno.daemon.grpc;
|
||||||
|
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.core.api.CoreApi;
|
import haveno.core.api.CoreApi;
|
||||||
import haveno.core.api.model.MarketDepthInfo;
|
import haveno.core.api.model.MarketDepthInfo;
|
||||||
import haveno.core.api.model.MarketPriceInfo;
|
import haveno.core.api.model.MarketPriceInfo;
|
||||||
@ -28,6 +29,7 @@ import haveno.proto.grpc.MarketPriceReply;
|
|||||||
import haveno.proto.grpc.MarketPriceRequest;
|
import haveno.proto.grpc.MarketPriceRequest;
|
||||||
import haveno.proto.grpc.MarketPricesReply;
|
import haveno.proto.grpc.MarketPricesReply;
|
||||||
import haveno.proto.grpc.MarketPricesRequest;
|
import haveno.proto.grpc.MarketPricesRequest;
|
||||||
|
import haveno.proto.grpc.PriceGrpc.PriceImplBase;
|
||||||
import io.grpc.ServerInterceptor;
|
import io.grpc.ServerInterceptor;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -38,7 +40,6 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||||
import static haveno.proto.grpc.PriceGrpc.PriceImplBase;
|
|
||||||
import static haveno.proto.grpc.PriceGrpc.getGetMarketPriceMethod;
|
import static haveno.proto.grpc.PriceGrpc.getGetMarketPriceMethod;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ class GrpcPriceService extends PriceImplBase {
|
|||||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||||
new HashMap<>() {{
|
new HashMap<>() {{
|
||||||
put(getGetMarketPriceMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getGetMarketPriceMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 1, SECONDS));
|
||||||
}}
|
}}
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package haveno.daemon.grpc;
|
package haveno.daemon.grpc;
|
||||||
|
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.core.api.CoreApi;
|
import haveno.core.api.CoreApi;
|
||||||
import haveno.core.api.model.TradeInfo;
|
import haveno.core.api.model.TradeInfo;
|
||||||
import haveno.core.trade.Trade;
|
import haveno.core.trade.Trade;
|
||||||
@ -38,6 +39,7 @@ import haveno.proto.grpc.SendChatMessageReply;
|
|||||||
import haveno.proto.grpc.SendChatMessageRequest;
|
import haveno.proto.grpc.SendChatMessageRequest;
|
||||||
import haveno.proto.grpc.TakeOfferReply;
|
import haveno.proto.grpc.TakeOfferReply;
|
||||||
import haveno.proto.grpc.TakeOfferRequest;
|
import haveno.proto.grpc.TakeOfferRequest;
|
||||||
|
import haveno.proto.grpc.TradesGrpc.TradesImplBase;
|
||||||
import io.grpc.ServerInterceptor;
|
import io.grpc.ServerInterceptor;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -50,7 +52,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static haveno.core.api.model.TradeInfo.toTradeInfo;
|
import static haveno.core.api.model.TradeInfo.toTradeInfo;
|
||||||
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||||
import static haveno.proto.grpc.TradesGrpc.TradesImplBase;
|
|
||||||
import static haveno.proto.grpc.TradesGrpc.getCompleteTradeMethod;
|
import static haveno.proto.grpc.TradesGrpc.getCompleteTradeMethod;
|
||||||
import static haveno.proto.grpc.TradesGrpc.getConfirmPaymentReceivedMethod;
|
import static haveno.proto.grpc.TradesGrpc.getConfirmPaymentReceivedMethod;
|
||||||
import static haveno.proto.grpc.TradesGrpc.getConfirmPaymentSentMethod;
|
import static haveno.proto.grpc.TradesGrpc.getConfirmPaymentSentMethod;
|
||||||
@ -235,15 +236,15 @@ class GrpcTradesService extends TradesImplBase {
|
|||||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||||
new HashMap<>() {{
|
new HashMap<>() {{
|
||||||
put(getGetTradeMethod().getFullMethodName(), new GrpcCallRateMeter(30, SECONDS));
|
put(getGetTradeMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 30 : 1, SECONDS));
|
||||||
put(getGetTradesMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getGetTradesMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 1, SECONDS));
|
||||||
put(getTakeOfferMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
|
put(getTakeOfferMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 20 : 3, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getConfirmPaymentSentMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getConfirmPaymentSentMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 3, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getConfirmPaymentReceivedMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getConfirmPaymentReceivedMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 3, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getCompleteTradeMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getCompleteTradeMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 3, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getWithdrawFundsMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
|
put(getWithdrawFundsMethod().getFullMethodName(), new GrpcCallRateMeter(3, MINUTES));
|
||||||
put(getGetChatMessagesMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getGetChatMessagesMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 1, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
put(getSendChatMessageMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
|
put(getSendChatMessageMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 10 : 1, Config.baseCurrencyNetwork().isTestnet() ? SECONDS : MINUTES));
|
||||||
}}
|
}}
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,12 @@
|
|||||||
package haveno.daemon.grpc;
|
package haveno.daemon.grpc;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.core.api.CoreApi;
|
import haveno.core.api.CoreApi;
|
||||||
import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor;
|
import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor;
|
||||||
import haveno.daemon.grpc.interceptor.GrpcCallRateMeter;
|
import haveno.daemon.grpc.interceptor.GrpcCallRateMeter;
|
||||||
|
import haveno.proto.grpc.GetVersionGrpc.GetVersionImplBase;
|
||||||
import haveno.proto.grpc.GetVersionReply;
|
import haveno.proto.grpc.GetVersionReply;
|
||||||
import haveno.proto.grpc.GetVersionRequest;
|
import haveno.proto.grpc.GetVersionRequest;
|
||||||
import io.grpc.ServerInterceptor;
|
import io.grpc.ServerInterceptor;
|
||||||
@ -32,7 +35,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||||
import static haveno.proto.grpc.GetVersionGrpc.GetVersionImplBase;
|
|
||||||
import static haveno.proto.grpc.GetVersionGrpc.getGetVersionMethod;
|
import static haveno.proto.grpc.GetVersionGrpc.getGetVersionMethod;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
|
||||||
@ -70,7 +72,7 @@ public class GrpcVersionService extends GetVersionImplBase {
|
|||||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||||
new HashMap<>() {{
|
new HashMap<>() {{
|
||||||
put(getGetVersionMethod().getFullMethodName(), new GrpcCallRateMeter(5, SECONDS));
|
put(getGetVersionMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 5 : 1, SECONDS));
|
||||||
}}
|
}}
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package haveno.daemon.grpc;
|
package haveno.daemon.grpc;
|
||||||
|
|
||||||
import haveno.common.UserThread;
|
import haveno.common.UserThread;
|
||||||
|
import haveno.common.config.Config;
|
||||||
import haveno.core.api.CoreApi;
|
import haveno.core.api.CoreApi;
|
||||||
import haveno.core.api.model.AddressBalanceInfo;
|
import haveno.core.api.model.AddressBalanceInfo;
|
||||||
import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor;
|
import haveno.daemon.grpc.interceptor.CallRateMeteringInterceptor;
|
||||||
@ -48,6 +49,7 @@ import haveno.proto.grpc.SetWalletPasswordReply;
|
|||||||
import haveno.proto.grpc.SetWalletPasswordRequest;
|
import haveno.proto.grpc.SetWalletPasswordRequest;
|
||||||
import haveno.proto.grpc.UnlockWalletReply;
|
import haveno.proto.grpc.UnlockWalletReply;
|
||||||
import haveno.proto.grpc.UnlockWalletRequest;
|
import haveno.proto.grpc.UnlockWalletRequest;
|
||||||
|
import haveno.proto.grpc.WalletsGrpc.WalletsImplBase;
|
||||||
import io.grpc.ServerInterceptor;
|
import io.grpc.ServerInterceptor;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -63,7 +65,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static haveno.core.api.model.XmrTx.toXmrTx;
|
import static haveno.core.api.model.XmrTx.toXmrTx;
|
||||||
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
import static haveno.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor;
|
||||||
import static haveno.proto.grpc.WalletsGrpc.WalletsImplBase;
|
|
||||||
import static haveno.proto.grpc.WalletsGrpc.getGetAddressBalanceMethod;
|
import static haveno.proto.grpc.WalletsGrpc.getGetAddressBalanceMethod;
|
||||||
import static haveno.proto.grpc.WalletsGrpc.getGetBalancesMethod;
|
import static haveno.proto.grpc.WalletsGrpc.getGetBalancesMethod;
|
||||||
import static haveno.proto.grpc.WalletsGrpc.getGetFundingAddressesMethod;
|
import static haveno.proto.grpc.WalletsGrpc.getGetFundingAddressesMethod;
|
||||||
@ -289,7 +290,7 @@ class GrpcWalletsService extends WalletsImplBase {
|
|||||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||||
new HashMap<>() {{
|
new HashMap<>() {{
|
||||||
put(getGetBalancesMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS)); // TODO: why do tests make so many calls to get balances?
|
put(getGetBalancesMethod().getFullMethodName(), new GrpcCallRateMeter(Config.baseCurrencyNetwork().isTestnet() ? 100 : 1, SECONDS)); // TODO: why do tests make so many calls to get balances?
|
||||||
put(getGetAddressBalanceMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
put(getGetAddressBalanceMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||||
put(getGetFundingAddressesMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
put(getGetFundingAddressesMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user