Categories
Cryptocurrency Development Ethereum

Not able to add ‘replayPastTransactionsFlowable’ transaction logs result into an collection List object using Web3j java?

I’m trying to create an api where i have to provide transaction logs in json objects but im unable to add result of replayPastTransactionsFlowable
into an collection object

    @GetMapping("/test")
public List<Transaction> test() throws InterruptedException, ExecutionException, IOException {
    String address = "0xeedc155ae507fb0a9becae6315286183a23229b0";
    List<Transaction> transactions = new ArrayList<Transaction>();
    Web3j web3j = web3jConfig.initializeWeb3j();
    System.out.println("test Running.......");
    BigInteger block = web3j.ethBlockNumber().send().getBlockNumber();
    System.out.println("blockno:" + block.intValue());
    int block_no = block.intValue();


Flowable<Transaction> replyBlocks   = web3j.replayPastTransactionsFlowable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST);
replyBlocks.forEach(temp->{
    System.out.println("into replyBlocks");
    System.out.println(temp.getBlockNumber());
        transactions.add(temp); //It's an collection object,and value is not adding into it 
})  ;

    return transactions;
}

}
Im using following two dep

    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>core</artifactId>
        <version>4.5.5</version>
    </dependency>

    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>contracts</artifactId>
        <version>4.5.5</version>
    </dependency>

Leave a Reply

Your email address will not be published. Required fields are marked *