drpc_pendingTransactions subscribe support (#673)

This commit is contained in:
Andrey Bronin
2025-06-06 14:13:28 +03:00
committed by GitHub
parent 5360d5eafb
commit 51719ee979
2 changed files with 4 additions and 4 deletions

View File

@@ -56,7 +56,7 @@ open class EthereumEgressSubscription(
const val METHOD_NEW_HEADS = "newHeads"
const val METHOD_LOGS = "logs"
const val METHOD_PENDING_TXES = "newPendingTransactions"
const val METHOD_PENDING_TXES_WITH_BODY = "newPendingTransactionsWithBody"
const val METHOD_DRPC_PENDING_TXES = "drpc_pendingTransactions"
}
private val newHeads = ConnectNewHeads(upstream, scheduler)
@@ -73,7 +73,7 @@ open class EthereumEgressSubscription(
listOf()
}
return if (pendingTxesSource != null) {
subs.plus(listOf(METHOD_PENDING_TXES, METHOD_PENDING_TXES_WITH_BODY))
subs.plus(listOf(METHOD_PENDING_TXES, METHOD_DRPC_PENDING_TXES))
} else {
subs
}
@@ -98,7 +98,7 @@ open class EthereumEgressSubscription(
}
if (topic == METHOD_PENDING_TXES) {
return pendingTxesSource?.connect(matcher) ?: Flux.empty()
} else if (topic == METHOD_PENDING_TXES_WITH_BODY) {
} else if (topic == METHOD_DRPC_PENDING_TXES) {
return pendingTxesSource?.connect(matcher)?.flatMap { txHash ->
// Create request to get full transaction
val request = ChainRequest(

View File

@@ -220,7 +220,7 @@ class EthereumEgressSubscriptionSpec extends Specification {
up3.start()
def ethereumSubscribe3 = new EthereumEgressSubscription(TestingCommons.multistream(up3) as GenericMultistream, Schedulers.boundedElastic(), Stub(PendingTxesSource))
then:
ethereumSubscribe3.getAvailableTopics().toSet() == [EthereumEgressSubscription.METHOD_LOGS, EthereumEgressSubscription.METHOD_NEW_HEADS, EthereumEgressSubscription.METHOD_PENDING_TXES, EthereumEgressSubscription.METHOD_PENDING_TXES_WITH_BODY].toSet()
ethereumSubscribe3.getAvailableTopics().toSet() == [EthereumEgressSubscription.METHOD_LOGS, EthereumEgressSubscription.METHOD_NEW_HEADS, EthereumEgressSubscription.METHOD_PENDING_TXES, EthereumEgressSubscription.METHOD_DRPC_PENDING_TXES].toSet()
when:
def up4 = TestingCommons.upstream(TestingCommons.api(), "eth_getBlockByNumber")
up4.getConnectorMock().setLiveness(Flux.just(HeadLivenessState.OK))