Skip to content

Commit 17aaa54

Browse files
authored
fix(resolver): drop in-memory resolution cache (#1151)
1 parent 808563e commit 17aaa54

1 file changed

Lines changed: 0 additions & 10 deletions

File tree

‎services/flipcash/src/main/kotlin/com/flipcash/services/controllers/ResolverController.kt‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.flipcash.services.repository.ResolverRepository
66
import com.flipcash.services.user.UserManager
77
import com.getcode.opencode.model.core.ID
88
import com.getcode.solana.keys.PublicKey
9-
import java.util.concurrent.ConcurrentHashMap
109
import javax.inject.Inject
1110
import javax.inject.Singleton
1211

@@ -15,13 +14,6 @@ class ResolverController @Inject constructor(
1514
private val repository: ResolverRepository,
1615
private val userManager: UserManager,
1716
) {
18-
// Memoizes successful resolutions for the process lifetime. An identity's on-chain address is
19-
// effectively immutable, and callers commonly resolve the same identity twice in quick
20-
// succession (e.g. a chat pre-resolves the recipient to gate the send button, then the payment
21-
// delegate resolves it again at send time) — the cache turns the second into a no-op. Failures
22-
// are never cached, so an unresolvable identity is retried.
23-
private val cache = ConcurrentHashMap<ResolveIdentifier, PublicKey>()
24-
2517
/** Resolves a phone number to its on-chain address. */
2618
suspend fun resolve(phone: ContactMethod.Phone): Result<PublicKey> =
2719
resolve(ResolveIdentifier.Phone(phone))
@@ -31,10 +23,8 @@ class ResolverController @Inject constructor(
3123
resolve(ResolveIdentifier.UserId(userId))
3224

3325
private suspend fun resolve(identifier: ResolveIdentifier): Result<PublicKey> {
34-
cache[identifier]?.let { return Result.success(it) }
3526
val owner = userManager.accountCluster?.authority?.keyPair
3627
?: return Result.failure(Throwable("No account cluster in UserManager"))
3728
return repository.resolve(owner, identifier)
38-
.onSuccess { cache[identifier] = it }
3929
}
4030
}

0 commit comments

Comments
 (0)