From 884a2bc0d46cb9874518617b8f87e94240520cf6 Mon Sep 17 00:00:00 2001 From: 257Byte <257byte@gmail.com> Date: Fri, 3 Mar 2023 01:28:17 +0300 Subject: [PATCH] Code smells --- Tzkt.Api/Parameters/ManagerOperationFilter.cs | 2 +- Tzkt.Api/Parameters/SrOperationFilter.cs | 2 +- Tzkt.Api/Parameters/SrRecoverBondOperationFilter.cs | 2 +- Tzkt.Sync/Services/Cache/RefutationGameCache.cs | 2 +- Tzkt.Sync/Services/Cache/SmartRollupCommitmentCache.cs | 2 +- Tzkt.Sync/Services/Cache/SmartRollupStakesCache.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tzkt.Api/Parameters/ManagerOperationFilter.cs b/Tzkt.Api/Parameters/ManagerOperationFilter.cs index 012961364..2cd3765fc 100644 --- a/Tzkt.Api/Parameters/ManagerOperationFilter.cs +++ b/Tzkt.Api/Parameters/ManagerOperationFilter.cs @@ -57,7 +57,7 @@ public class ManagerOperationFilter : INormalizable status == null && sender == null; - public virtual string Normalize(string prop) + public virtual string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("hash", hash), ("counter", counter), ("level", level), diff --git a/Tzkt.Api/Parameters/SrOperationFilter.cs b/Tzkt.Api/Parameters/SrOperationFilter.cs index 14e201a1d..8df6d3286 100644 --- a/Tzkt.Api/Parameters/SrOperationFilter.cs +++ b/Tzkt.Api/Parameters/SrOperationFilter.cs @@ -12,7 +12,7 @@ public class SrOperationFilter : ManagerOperationFilter public override bool Empty => base.Empty && rollup == null; - public override string Normalize(string prop) + public override string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("hash", hash), ("counter", counter), ("level", level), diff --git a/Tzkt.Api/Parameters/SrRecoverBondOperationFilter.cs b/Tzkt.Api/Parameters/SrRecoverBondOperationFilter.cs index 45f9136da..781772558 100644 --- a/Tzkt.Api/Parameters/SrRecoverBondOperationFilter.cs +++ b/Tzkt.Api/Parameters/SrRecoverBondOperationFilter.cs @@ -20,7 +20,7 @@ public class SrRecoverBondOperationFilter : SrOperationFilter public override bool Empty => base.Empty && staker == null && anyof == null; - public override string Normalize(string prop) + public override string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("hash", hash), ("counter", counter), ("level", level), diff --git a/Tzkt.Sync/Services/Cache/RefutationGameCache.cs b/Tzkt.Sync/Services/Cache/RefutationGameCache.cs index 7cb93d34c..e209d81eb 100644 --- a/Tzkt.Sync/Services/Cache/RefutationGameCache.cs +++ b/Tzkt.Sync/Services/Cache/RefutationGameCache.cs @@ -38,7 +38,7 @@ public void Trim() { var toRemove = CachedByKey.Values .OrderBy(x => x.LastLevel) - .Take(MaxItems / 2) + .Take(CachedByKey.Count - (int)(MaxItems * 0.75)) .ToList(); foreach (var item in toRemove) diff --git a/Tzkt.Sync/Services/Cache/SmartRollupCommitmentCache.cs b/Tzkt.Sync/Services/Cache/SmartRollupCommitmentCache.cs index 721afb7a7..db335dc8b 100644 --- a/Tzkt.Sync/Services/Cache/SmartRollupCommitmentCache.cs +++ b/Tzkt.Sync/Services/Cache/SmartRollupCommitmentCache.cs @@ -36,7 +36,7 @@ public void Trim() { var toRemove = CachedByKey.Values .OrderBy(x => x.LastLevel) - .Take(MaxItems / 2) + .Take(CachedByKey.Count - (int)(MaxItems * 0.75)) .ToList(); foreach (var item in toRemove) diff --git a/Tzkt.Sync/Services/Cache/SmartRollupStakesCache.cs b/Tzkt.Sync/Services/Cache/SmartRollupStakesCache.cs index cf2a9164a..8c0c969ae 100644 --- a/Tzkt.Sync/Services/Cache/SmartRollupStakesCache.cs +++ b/Tzkt.Sync/Services/Cache/SmartRollupStakesCache.cs @@ -35,7 +35,7 @@ public void Remove(int commitmentId, int stakerId) public void Trim() { - if (Cache.Count > Cache.Count) + if (Cache.Count > MaxItems) { var toRemove = Cache.Keys .OrderBy(x => x)