problem: fails to respond when requested block doesn't exist

This commit is contained in:
Igor Artamonov
2021-06-07 12:28:01 -04:00
parent 8424288de2
commit 91ffb0212e
3 changed files with 90 additions and 3 deletions

View File

@@ -114,9 +114,13 @@ class EthereumDirectReader(
return readWithQuorum(request)
.timeout(Defaults.timeoutInternal, Mono.error(TimeoutException("Block not read $id")))
.retryWhen(Retry.backoff(3, Duration.ofSeconds(1)))
.map { blockbytes ->
val block = objectMapper.readValue(blockbytes, BlockJson::class.java) as BlockJson<TransactionRefJson>
BlockContainer.from(block, blockbytes)
.flatMap { blockbytes ->
val block = objectMapper.readValue(blockbytes, BlockJson::class.java) as BlockJson<TransactionRefJson>?
if (block == null) {
Mono.empty<BlockContainer>()
} else {
Mono.just(BlockContainer.from(block, blockbytes))
}
}
.doOnNext { block ->
caches.cache(Caches.Tag.REQUESTED, block)