v2.2.0 A historical perspective
Observable API enhcements
This release provides a number of enhancements to web3j's Observable API. You can now request historical ranges of blocks from the blockchain on demand.
To replay a range of blocks from the blockchain:
Subscription subscription = web3j.replayBlocksObservable(
<startBlockNumber>, <endBlockNumber>, <fullTxObjects>)
.subscribe(block -> {
...
});
To replay the individual transactions contained within a range of blocks:
Subscription subscription = web3j.replayTransactionsObservable(
<startBlockNumber>, <endBlockNumber>)
.subscribe(tx -> {
...
});
You can also get web3j to replay all blocks up to the most current, and provide notification
(via the submitted Observable) once you've caught up:
Subscription subscription = web3j.catchUpToLatestBlockObservable(
<startBlockNumber>, <fullTxObjects>, <onCompleteObservable>)
.subscribe(block -> {
...
});
Or, if you'd rather replay all blocks to the most current, then be notified of new subsequent
blocks being created:
Subscription subscription = web3j.catchUpToLatestAndSubscribeToNewBlocksObservable(
<startBlockNumber>, <fullTxObjects>)
.subscribe(block -> {
...
});
I was able to replay the entire Ropsten blockchain ex. transactions (941667 blocks) in 7m22s. All transactions from Ropsten could be replayed in 41m16s on a 2013 Macbook Pro. Just make sure you use IPC to connect to your Ethereum node.
Smart contract wrapper event Observables also now provide startBlock and endBlockParameters, so you can specify the range with which you want the log or event filters to cover.
For further information refer to the filters documentation.
Smart contract verification
Smart contract wrappers now include an isValid() method to verify that the deployed bytecode at the smart contract's address matches that of the smart contract wrapper.
Long parameter values added to Solidity integer types
All of the Uint and Int Solidity types now support construction with long values, instead of only BigIntegers as was previously the case. DefaultBlockParameterNumber's also now accept long values.
Async changes
Behind the scenes in the smart contract wrappers, web3j now performs synchronous requests with Ethereum clients. This is to reduce the overhead that CompletableFutures were placing on the JVM thread pool. Completable futures are now only used in the client API for smart contract wrappers.
Other issues/pull requests
- msg.sender not set properly in contract function call (#89)
- Expose SolidityFunctionWrapperGenerator Method for other libaries (#86)
- Add initial value documentation (#73)
- Fix problems around size validation of large uint values (#71)
- Calls on contract hang after event subscription (#69)
- Sign.signedMessageToKey() can't be called because the Sign.SignatureData class is not public. (#64)
- Java smart contract wrappers does not support ABI with type of "address[] storage" (#63)
- Nonce calculated without counting pendig tx (#54)