Height matcher to proxy (#340)
This commit is contained in:
@@ -285,9 +285,12 @@ open class NativeCall(
|
||||
),
|
||||
)
|
||||
}
|
||||
val requestMatcher = requestItem.selectorsList
|
||||
.takeIf { it.isNotEmpty() }
|
||||
?.run { Mono.just(Selector.convertToMatcher(this, upstream.getHead())) }
|
||||
// for ethereum the actual block needed for the call may be specified in the call parameters
|
||||
val callSpecificMatcher: Mono<Selector.Matcher> =
|
||||
upstream.callSelector?.getMatcher(method, params, upstream.getHead(), passthrough) ?: Mono.empty()
|
||||
requestMatcher ?: upstream.callSelector?.getMatcher(method, params, upstream.getHead(), passthrough) ?: Mono.empty()
|
||||
return callSpecificMatcher.defaultIfEmpty(Selector.empty).map { csm ->
|
||||
val matcher = Selector.Builder()
|
||||
.withMatcher(csm)
|
||||
|
||||
@@ -39,6 +39,26 @@ class Selector {
|
||||
@JvmStatic
|
||||
val anyLabel = AnyLabelMatcher()
|
||||
|
||||
@JvmStatic
|
||||
fun convertToMatcher(selectors: List<BlockchainOuterClass.Selector>, head: Head): Matcher {
|
||||
return selectors
|
||||
.map {
|
||||
when {
|
||||
it.hasHeightSelector() -> {
|
||||
val height = if (it.heightSelector.height == -1L) head.getCurrentHeight() else it.heightSelector.height
|
||||
if (height == null) {
|
||||
empty
|
||||
} else {
|
||||
HeightMatcher(height)
|
||||
}
|
||||
}
|
||||
else -> empty
|
||||
}
|
||||
}.run {
|
||||
MultiMatcher(this)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun convertToMatcher(req: BlockchainOuterClass.Selector?): LabelSelectorMatcher {
|
||||
return when {
|
||||
|
||||
Reference in New Issue
Block a user