Package 

Class CompactBlockDownloader


  • 
    public class CompactBlockDownloader
    
                        

    Serves as a source of compact blocks received from the light wallet server. Once started, it will use the given lightWallet client to request all the appropriate blocks and compact block store to persist them. By delegating to these dependencies, the downloader remains agnostic to the particular implementation of how to retrieve and store data; although, by default the SDK uses gRPC and SQL.

    • Method Summary

      Modifier and Type Method Description
      final CompactBlockRepository getCompactBlockRepository()
      final List<JniBlockMeta> downloadBlockRange(ClosedRange<BlockHeight> heightRange, ServiceMode serviceMode) Requests the given range of blocks from the lightWalletClient and then persists them to the compactBlockStore.
      final Unit rewindToHeight(BlockHeight height) Rewind the storage to the given height, usually to handle reorgs.
      final Response<BlockHeightUnsafe> getLatestBlockHeight(ServiceMode serviceMode) Return the latest block height known by the lightWalletClient.
      final BlockHeight getLastDownloadedHeight() Return the latest block height that has been persisted into the CompactBlockRepository.
      final LightWalletEndpointInfoUnsafe getServerInfo(ServiceMode serviceMode)
      final Unit stop() Stop this downloader and cleanup any resources being used.
      final Unit reconnect() Reconnect to the same or a different server.
      final Response<RawTransactionUnsafe> fetchTransaction(ByteArray txId, ServiceMode serviceMode) Fetch the details of a known transaction.
      final <ERROR CLASS> getTAddressTransactions(String transparentAddress, ClosedRange<BlockHeight> blockHeightRange, ServiceMode serviceMode) Get transactions belonging to the given transparent address
      final Flow<Response<GetAddressUtxosReplyUnsafe>> fetchUtxos(List<String> tAddresses, BlockHeightUnsafe startHeight, ServiceMode serviceMode) Fetch all UTXOs for the given addresses and from the given height.
      final Flow<Response<SubtreeRootUnsafe>> getSubtreeRoots(UInt startIndex, ShieldedProtocolEnum shieldedProtocol, UInt maxEntries, ServiceMode serviceMode) Returns a stream of information about roots of subtrees of the Sapling and Orchard note commitment trees.
      final Response<TreeStateUnsafe> getTreeState(BlockHeightUnsafe height, ServiceMode serviceMode) Returns information about roots of subtrees of the Sapling and Orchard note commitment trees.
      final Flow<Response<RawTransactionUnsafe>> observeMempool(ServiceMode serviceMode)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CompactBlockDownloader

        CompactBlockDownloader(CombinedWalletClient walletClient, CompactBlockRepository compactBlockRepository)
    • Method Detail

      • downloadBlockRange

         final List<JniBlockMeta> downloadBlockRange(ClosedRange<BlockHeight> heightRange, ServiceMode serviceMode)

        Requests the given range of blocks from the lightWalletClient and then persists them to the compactBlockStore.

        Parameters:
        heightRange - the inclusive range of heights to request.
      • rewindToHeight

         final Unit rewindToHeight(BlockHeight height)

        Rewind the storage to the given height, usually to handle reorgs. Deletes all blocks above the given height.

        Parameters:
        height - the height to which the data will rewind.
      • getLatestBlockHeight

         final Response<BlockHeightUnsafe> getLatestBlockHeight(ServiceMode serviceMode)

        Return the latest block height known by the lightWalletClient.

      • getServerInfo

         final LightWalletEndpointInfoUnsafe getServerInfo(ServiceMode serviceMode)
      • stop

         final Unit stop()

        Stop this downloader and cleanup any resources being used.

      • reconnect

         final Unit reconnect()

        Reconnect to the same or a different server. This is useful when the connection is unrecoverable. That might be time to switch to a mirror or just reconnect.

      • fetchTransaction

         final Response<RawTransactionUnsafe> fetchTransaction(ByteArray txId, ServiceMode serviceMode)

        Fetch the details of a known transaction.

      • fetchUtxos

         final Flow<Response<GetAddressUtxosReplyUnsafe>> fetchUtxos(List<String> tAddresses, BlockHeightUnsafe startHeight, ServiceMode serviceMode)

        Fetch all UTXOs for the given addresses and from the given height.

      • getSubtreeRoots

         final Flow<Response<SubtreeRootUnsafe>> getSubtreeRoots(UInt startIndex, ShieldedProtocolEnum shieldedProtocol, UInt maxEntries, ServiceMode serviceMode)

        Returns a stream of information about roots of subtrees of the Sapling and Orchard note commitment trees.

      • getTreeState

         final Response<TreeStateUnsafe> getTreeState(BlockHeightUnsafe height, ServiceMode serviceMode)

        Returns information about roots of subtrees of the Sapling and Orchard note commitment trees.

      • observeMempool

         final Flow<Response<RawTransactionUnsafe>> observeMempool(ServiceMode serviceMode)