Fix issues with caches
- Fix read block - Fix read not enrich blocks, refactoring read tx receipts
This commit is contained in:
Submodule emerald-grpc updated: 37a356fdee...1c9a9554e6
@@ -35,12 +35,13 @@ open class BlocksMemCache(
|
||||
}
|
||||
|
||||
open fun get(key: BlockId): BlockContainer? {
|
||||
return mapping.getIfPresent(key)?.let {
|
||||
return@let if (it.enriched) it else null
|
||||
}
|
||||
return mapping.getIfPresent(key)
|
||||
}
|
||||
|
||||
open fun add(block: BlockContainer) {
|
||||
if (!block.enriched) {
|
||||
return
|
||||
}
|
||||
mapping.put(block.hash, block)
|
||||
}
|
||||
|
||||
|
||||
@@ -121,10 +121,11 @@ class EthereumDirectReader(
|
||||
return readWithQuorum(request)
|
||||
.timeout(Defaults.timeoutInternal, Mono.error(TimeoutException("Receipt not read $key")))
|
||||
.flatMap { json ->
|
||||
try {
|
||||
// Caching needs some additional data (ex. Height) to make a decision on how long and where to cache
|
||||
// So we have to parse the JSON here and extract reference data
|
||||
val receipt = objectMapper.readValue(json, TransactionReceiptJson::class.java)
|
||||
val receipt = objectMapper.readValue(json, TransactionReceiptJson::class.java)
|
||||
if (receipt == null) {
|
||||
log.debug("Empty receipt for txId $key")
|
||||
Mono.empty()
|
||||
} else {
|
||||
caches.cacheReceipt(
|
||||
Caches.Tag.REQUESTED,
|
||||
DefaultContainer(
|
||||
@@ -135,11 +136,8 @@ class EthereumDirectReader(
|
||||
parsed = receipt
|
||||
)
|
||||
)
|
||||
} catch (t: Throwable) {
|
||||
log.warn("Failed to cache Tx Receipt", t)
|
||||
return@flatMap Mono.empty()
|
||||
Mono.just(json)
|
||||
}
|
||||
Mono.just(json)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ open class WsConnectionImpl(
|
||||
)
|
||||
val sender = currentRequests.remove(msg.id.asNumber().toInt())
|
||||
if (sender == null) {
|
||||
log.warn("Unknown response received for ${msg.id} with body ${msg.value?.let { String(it) }}")
|
||||
log.warn("Unknown response received for ${msg.id}")
|
||||
} else {
|
||||
try {
|
||||
val emitResult = sender.tryEmitValue(rpcResponse)
|
||||
|
||||
Reference in New Issue
Block a user