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.

    • Constructor Detail

      • CompactBlockDownloader

        CompactBlockDownloader(LightWalletClient lightWalletClient, CompactBlockRepository compactBlockRepository)
    • Method Detail

      • downloadBlockRange

         final List<JniBlockMeta> downloadBlockRange(ClosedRange<BlockHeight> heightRange)

        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()

        Return the latest block height known by the lightWalletClient.

      • getServerInfo

         final LightWalletEndpointInfoUnsafe getServerInfo()
      • 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)

        Fetch the details of a known transaction.

      • fetchUtxos

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

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

      • getSubtreeRoots

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

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

      • getTreeState

         final Response<TreeStateUnsafe> getTreeState(BlockHeightUnsafe height)

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