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