Usage example for: TransactionServiceGrpc.TransactionServiceStub.getTransactionTrees

Hi,

I am not able to receive any transaction trees when subscribing with TransactionServiceGrpc.TransactionServiceStub.getTransactionTrees.

If I pass in a GetTransactionsRequest with a TransactionFilter as I would for GetTransactions (which works fine btw) I get an error saying getTransactionTrees cannot filter by templates.

If I pass an empty filter - TransactionFilter filter = new FiltersByParty(Map.of()) - I don’t get the error anymore but I don’t receive any transaction tree.

The only way I can get TransactionTree is when using commandService..submitAndWaitForTransactionTree(...)

Also, I was not able to find any example of using TransactionServiceStub.getTransactionTrees.

Can anyone please advise ?

thanks,
Emil

You have to specify the party but no templates in your filter. So something like the following:

TransactionFilter filter = new FiltersByParty(Collections.singletonMap(party, new InclusiveFilter())

Thanks. There is no default constructor in InclusiveFilter, only one that takes a set of templates. If I pass in an empty set I still get:

io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Invalid argument: inviter-c13e4fb0-7226-4756-8c22-17a4d0b496e4 attempted subscription for templates []. Template filtration is not supported on GetTransactionTrees RPC. To get filtered data, use the GetTransactions RPC.
at io.grpc.Status.asRuntimeException(Status.java:533)
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:453)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)
at io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:689)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$900(ClientCallImpl.java:577)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:751)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:740)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

but you set me on the right track, this works:

TransactionFilter filter = new FiltersByParty(Map.of(party, NoFilter.instance))

2 Likes