Package 

Class CompactBlockProcessor


  • 
    public final class CompactBlockProcessor
    
                        

    Responsible for processing the compact blocks that are received from the lightwallet server. This class encapsulates all the business logic required to validate and scan the blockchain and is therefore tightly coupled with librustzcash.

    • Method Detail

      • getOnChainErrorListener

         final Function2<BlockHeight, BlockHeight, Object> getOnChainErrorListener()

        Callback for reorgs. This callback is invoked when validation fails with the height at which an error was found and the lower bound to which the data will rewind, at most.

      • setOnChainErrorListener

         final Unit setOnChainErrorListener(Function2<BlockHeight, BlockHeight, Object> onChainErrorListener)

        Callback for reorgs. This callback is invoked when validation fails with the height at which an error was found and the lower bound to which the data will rewind, at most.

      • getOnSetupErrorListener

         final Function1<Throwable, Boolean> getOnSetupErrorListener()

        Callback for setup errors that occur prior to processing compact blocks. Can be used to override any errors from verifySetup. When this listener is missing then all setup errors will result in the processor not starting. This is particularly useful for wallets to receive a callback right before the SDK will reject a lightwalletd server because it appears not to match.

      • setOnSetupErrorListener

         final Unit setOnSetupErrorListener(Function1<Throwable, Boolean> onSetupErrorListener)

        Callback for setup errors that occur prior to processing compact blocks. Can be used to override any errors from verifySetup. When this listener is missing then all setup errors will result in the processor not starting. This is particularly useful for wallets to receive a callback right before the SDK will reject a lightwalletd server because it appears not to match.

      • getNetwork

         final ZcashNetwork getNetwork()

        The zcash network that is being processed. Either Testnet or Mainnet.

      • getState

         final <ERROR CLASS> getState()

        The flow of state values so that a wallet can monitor the state of this class without needing to poll.

      • getProgress

         final <ERROR CLASS> getProgress()

        The flow of progress values so that a wallet can monitor how much downloading remains without needing to poll.

      • getProcessorInfo

         final <ERROR CLASS> getProcessorInfo()

        The flow of detailed processorInfo like the range of blocks that shall be downloaded and scanned. This gives the wallet a lot of insight into the work of this processor.

      • getNetworkHeight

         final <ERROR CLASS> getNetworkHeight()

        The flow of network height. This value is updated at the same time that processorInfo is updated but this allows consumers to have the information pushed instead of polling.

      • getBirthdayHeight

         final <ERROR CLASS> getBirthdayHeight()

        The first block this wallet cares about anything prior can be ignored. If a wallet has no transactions, this value will later update to 100 blocks before the first transaction, rounded down to the nearest 100. So in some cases, this is a dynamic value.

      • getFullyScannedHeight

         final <ERROR CLASS> getFullyScannedHeight()

        The flow of fully scanned height. This value is updated at the same time as the other values from WalletSummary. fullyScannedHeight is the height below which all blocks have been scanned by the wallet, ignoring blocks below the wallet birthday. This allows consumers to have the information pushed instead of polling.

        We can consider moving this property to public API by creating equivalent property on Synchronizer

      • start

         final Unit start()

        Download compact blocks, verify and scan them until stop is called.

      • checkErrorAndFail

         final Boolean checkErrorAndFail(BlockHeight failedHeight, Throwable failCause)

        Checks the block synchronization retry attempts and fails with throwing the failCause error once RETRIES count is reached.

        Parameters:
        failedHeight - The height at which the block processing failed
        failCause - The cause of the failure to be part of thrown exception