diff --git a/emerald-grpc b/emerald-grpc index ab1380831..b95b14299 160000 --- a/emerald-grpc +++ b/emerald-grpc @@ -1 +1 @@ -Subproject commit ab1380831c74c3cced94b87db1b90d0856755c8e +Subproject commit b95b142993aec346dc9392bdce03cd6edfc3b9f6 diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt index f681e41ac..cb81ad91b 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/Selector.kt @@ -65,10 +65,18 @@ class Selector { }.run { MultiMatcher(this) } - val sort = selectors.firstOrNull { it.hasHeightSelector() && it.heightSelector.height == -1L } - ?.let { Sort(compareByDescending { it.getHead().getCurrentHeight() }) } - ?: Sort.default - return UpstreamFilter(sort, matcher) + return UpstreamFilter(getSort(selectors), matcher) + } + + private fun getSort(selectors: List): Sort { + selectors.forEach { selector -> + if (selector.hasHeightSelector() && selector.heightSelector.height == -1L) { + return Sort(compareByDescending { it.getHead().getCurrentHeight() }) + } else if (selector.hasLowerHeightSelector() && selector.lowerHeightSelector.height == 0L) { + return Sort(compareBy(nullsLast()) { it.getHead().getCurrentHeight() }) + } + } + return Sort.default } @JvmStatic