Apply method matcher for direct reader (#200)
This commit is contained in:
@@ -127,7 +127,7 @@ class Selector {
|
|||||||
fun describeInternal(): String
|
fun describeInternal(): String
|
||||||
}
|
}
|
||||||
|
|
||||||
class MultiMatcher(
|
data class MultiMatcher(
|
||||||
private val matchers: Collection<Matcher>
|
private val matchers: Collection<Matcher>
|
||||||
) : Matcher {
|
) : Matcher {
|
||||||
override fun matches(up: Upstream): Boolean {
|
override fun matches(up: Upstream): Boolean {
|
||||||
@@ -156,7 +156,7 @@ class Selector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MethodMatcher(
|
data class MethodMatcher(
|
||||||
val method: String
|
val method: String
|
||||||
) : Matcher {
|
) : Matcher {
|
||||||
override fun matches(up: Upstream): Boolean {
|
override fun matches(up: Upstream): Boolean {
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ class EthereumDirectReader(
|
|||||||
return Mono.just(quorumReaderFactory)
|
return Mono.just(quorumReaderFactory)
|
||||||
.map {
|
.map {
|
||||||
it.create(
|
it.create(
|
||||||
up.getApiSource(matcher),
|
up.getApiSource(
|
||||||
|
Selector.Builder()
|
||||||
|
.withMatcher(matcher)
|
||||||
|
.forMethod(request.method)
|
||||||
|
.build()
|
||||||
|
),
|
||||||
callMethodsFactory.create().createQuorumFor(request.method),
|
callMethodsFactory.create().createQuorumFor(request.method),
|
||||||
// we do not use Signer for internal requests because it doesn't make much sense
|
// we do not use Signer for internal requests because it doesn't make much sense
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -113,7 +113,9 @@ class EthereumDirectReaderSpec extends Specification {
|
|||||||
transactions = []
|
transactions = []
|
||||||
}
|
}
|
||||||
def up = Mock(Multistream) {
|
def up = Mock(Multistream) {
|
||||||
1 * getApiSource(new Selector.HeightMatcher(100)) >> Stub(ApiSource)
|
1 * getApiSource(
|
||||||
|
new Selector.Builder().withMatcher(new Selector.HeightMatcher(100)).forMethod("eth_getBlockByNumber").build()
|
||||||
|
) >> Stub(ApiSource)
|
||||||
}
|
}
|
||||||
def calls = Mock(Factory) {
|
def calls = Mock(Factory) {
|
||||||
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
1 * create() >> new DefaultEthereumMethods(Chain.ETHEREUM)
|
||||||
|
|||||||
Reference in New Issue
Block a user