1

I can´t find where is the Web3j ethLogObservable method. I can´t find in GitHub repo

UnexpectedCharacter
  • 852
  • 1
  • 11
  • 30

2 Answers2

4

From its version 4.0, web3j started using RxJava 2.0 FLowable instead of RxJava 2.0 Obsersable to handle events processing, notably because Flowable are much more efficient during high load using a backpressure mechanism.

The new function to catch events is now the following:

EthFilter filter = new EthFilter(
        DefaultBlockParameterName.EARLIEST, 
        DefaultBlockParameterName.LATEST, 
        contractAddress);

web3.ethLogFlowable(filter).subscribe(event -> {
    log.info("event = {}", event);
});

You can find more info here

EDIT: fixed URL

Greg Jeanmart
  • 7,207
  • 2
  • 19
  • 35
0

I can't run ethLogFlowable...

The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling

  • It doesn't seems to be an answer. What are you trying to say? – Ismael Nov 05 '22 at 05:11
  • if you check subscribe method, there's an overload for it that plus the onNext block, accepts onError block too. You should pass a function to this argument so further errors will be handled. – Ahmad Reza Enshaee Apr 02 '23 at 05:23