Skip to content

Commit

Permalink
Check CallLimitValidator only at startup (#479)
Browse files Browse the repository at this point in the history
* Check CallLimitValidator only at startup checks

* simplify code
  • Loading branch information
tonatoz authored May 20, 2024
1 parent f6090a4 commit 4f36257
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ abstract class UpstreamValidator(

abstract fun validateUpstreamSettings(): Mono<ValidateUpstreamSettingsResult>

fun validateUpstreamSettingsOnStartup(): ValidateUpstreamSettingsResult {
return validateUpstreamSettings().block() ?: ValidateUpstreamSettingsResult.UPSTREAM_FATAL_SETTINGS_ERROR
open fun validateUpstreamSettingsOnStartup(): ValidateUpstreamSettingsResult {
return ValidateUpstreamSettingsResult.UPSTREAM_VALID
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,23 @@ open class EthereumUpstreamValidator @JvmOverloads constructor(
}
return Mono.zip(
validateChain(),
validateCallLimit(),
validateOldBlocks(),
).map {
listOf(it.t1, it.t2, it.t3).sorted().last()
listOf(it.t1, it.t2).maxOf { it }
}
}

override fun validateUpstreamSettingsOnStartup(): ValidateUpstreamSettingsResult {
if (options.disableUpstreamValidation) {
return ValidateUpstreamSettingsResult.UPSTREAM_VALID
}
return Mono.zip(
validateChain(),
validateOldBlocks(),
validateCallLimit(),
).map {
listOf(it.t1, it.t2, it.t3).maxOf { it }
}.block() ?: ValidateUpstreamSettingsResult.UPSTREAM_SETTINGS_ERROR
}

private fun validateChain(): Mono<ValidateUpstreamSettingsResult> {
Expand Down

0 comments on commit 4f36257

Please sign in to comment.