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? {
|
open fun get(key: BlockId): BlockContainer? {
|
||||||
return mapping.getIfPresent(key)?.let {
|
return mapping.getIfPresent(key)
|
||||||
return@let if (it.enriched) it else null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun add(block: BlockContainer) {
|
open fun add(block: BlockContainer) {
|
||||||
|
if (!block.enriched) {
|
||||||
|
return
|
||||||
|
}
|
||||||
mapping.put(block.hash, block)
|
mapping.put(block.hash, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,10 +121,11 @@ class EthereumDirectReader(
|
|||||||
return readWithQuorum(request)
|
return readWithQuorum(request)
|
||||||
.timeout(Defaults.timeoutInternal, Mono.error(TimeoutException("Receipt not read $key")))
|
.timeout(Defaults.timeoutInternal, Mono.error(TimeoutException("Receipt not read $key")))
|
||||||
.flatMap { json ->
|
.flatMap { json ->
|
||||||
try {
|
val receipt = objectMapper.readValue(json, TransactionReceiptJson::class.java)
|
||||||
// Caching needs some additional data (ex. Height) to make a decision on how long and where to cache
|
if (receipt == null) {
|
||||||
// So we have to parse the JSON here and extract reference data
|
log.debug("Empty receipt for txId $key")
|
||||||
val receipt = objectMapper.readValue(json, TransactionReceiptJson::class.java)
|
Mono.empty()
|
||||||
|
} else {
|
||||||
caches.cacheReceipt(
|
caches.cacheReceipt(
|
||||||
Caches.Tag.REQUESTED,
|
Caches.Tag.REQUESTED,
|
||||||
DefaultContainer(
|
DefaultContainer(
|
||||||
@@ -135,11 +136,8 @@ class EthereumDirectReader(
|
|||||||
parsed = receipt
|
parsed = receipt
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} catch (t: Throwable) {
|
Mono.just(json)
|
||||||
log.warn("Failed to cache Tx Receipt", t)
|
|
||||||
return@flatMap Mono.empty()
|
|
||||||
}
|
}
|
||||||
Mono.just(json)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ open class WsConnectionImpl(
|
|||||||
)
|
)
|
||||||
val sender = currentRequests.remove(msg.id.asNumber().toInt())
|
val sender = currentRequests.remove(msg.id.asNumber().toInt())
|
||||||
if (sender == null) {
|
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 {
|
} else {
|
||||||
try {
|
try {
|
||||||
val emitResult = sender.tryEmitValue(rpcResponse)
|
val emitResult = sender.tryEmitValue(rpcResponse)
|
||||||
|
|||||||
Reference in New Issue
Block a user