-
public class CompactBlockDownloaderServes 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classCompactBlockDownloader.Companion
-
Field Summary
Fields Modifier and Type Field Description private final CompactBlockRepositorycompactBlockRepository
-
Constructor Summary
Constructors Constructor Description CompactBlockDownloader(CombinedWalletClient walletClient, CompactBlockRepository compactBlockRepository)
-
Method Summary
Modifier and Type Method Description final CompactBlockRepositorygetCompactBlockRepository()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 UnitrewindToHeight(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 BlockHeightgetLastDownloadedHeight()Return the latest block height that has been persisted into the CompactBlockRepository. final LightWalletEndpointInfoUnsafegetServerInfo(ServiceMode serviceMode)final Unitstop()Stop this downloader and cleanup any resources being used. final Unitreconnect()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)-
-
Constructor Detail
-
CompactBlockDownloader
CompactBlockDownloader(CombinedWalletClient walletClient, CompactBlockRepository compactBlockRepository)
-
-
Method Detail
-
getCompactBlockRepository
final CompactBlockRepository getCompactBlockRepository()
-
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.
-
getLastDownloadedHeight
final BlockHeight getLastDownloadedHeight()
Return the latest block height that has been persisted into the CompactBlockRepository.
-
getServerInfo
final LightWalletEndpointInfoUnsafe getServerInfo(ServiceMode serviceMode)
-
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.
-
getTAddressTransactions
final <ERROR CLASS> getTAddressTransactions(String transparentAddress, ClosedRange<BlockHeight> blockHeightRange, ServiceMode serviceMode)
Get transactions belonging to the given transparent address
-
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)
-
-
-
-