problem: caching is not verified
This commit is contained in:
@@ -108,6 +108,10 @@ class NativeCall(
|
||||
|
||||
fun fetch(ctx: CallContext<ParsedCallDetails>): Mono<CallContext<ByteArray>> {
|
||||
return fetchFromCache(ctx)
|
||||
.onErrorResume { t ->
|
||||
log.warn("Failed to read from cache", t);
|
||||
Mono.empty()
|
||||
}
|
||||
.switchIfEmpty(
|
||||
Mono.just(ctx).flatMap(this::executeOnRemote)
|
||||
)
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.infinitape.etherjar.hex.HexQuantity
|
||||
import io.infinitape.etherjar.rpc.json.BlockJson
|
||||
import io.infinitape.etherjar.rpc.json.ResponseJson
|
||||
import io.infinitape.etherjar.rpc.json.TransactionRefJson
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
import java.util.function.Function
|
||||
|
||||
@@ -37,6 +38,8 @@ open class CachingEthereumApi(
|
||||
): EthereumApi(objectMapper) {
|
||||
|
||||
companion object {
|
||||
private val log = LoggerFactory.getLogger(CachingEthereumApi::class.java)
|
||||
|
||||
@JvmStatic
|
||||
fun empty(): CachingEthereumApi {
|
||||
return CachingEthereumApi(ObjectMapper(), EmptyReader(), EmptyEthereumHead())
|
||||
@@ -55,6 +58,10 @@ open class CachingEthereumApi(
|
||||
.map { BlockHash.from(it as String) }
|
||||
.flatMap(cache::read)
|
||||
.map(toJson(id))
|
||||
.onErrorResume { t ->
|
||||
log.warn("Error during read from cache", t)
|
||||
Mono.empty()
|
||||
}
|
||||
else Mono.empty()
|
||||
else ->
|
||||
Mono.empty()
|
||||
|
||||
Reference in New Issue
Block a user