# CompactBlockDownloading

    public protocol CompactBlockDownloading

Represents what a compact block downloaded should provide to its clients

- `downloadBlockRange(_:completion:)`

  Downloads and stores the given block range. Non-Blocking

  #### Declaration

  Swift

      func downloadBlockRange(
          _ heightRange: CompactBlockRange,
          completion: @escaping (Error?) -> Void
      )

- `rewind(to:completion:)`

  Remove newer blocks and go back to the given height

  #### Declaration

  Swift

      func rewind(to height: BlockHeight, completion: @escaping (Error?) -> Void)

  #### Parameters

  `height` | the given height to rewind to
  `completion` | block to be executed after completing rewind

- `lastDownloadedBlockHeight(result:)`

  returns the height of the latest compact block stored locally BlockHeight.empty() if no blocks are stored yet non-blocking

  #### Declaration

  Swift

      func lastDownloadedBlockHeight(result: @escaping (Result<BlockHeight, Error>) -> Void)

- `latestBlockHeight(result:)`

  Returns the last height on the blockchain Non-blocking

  #### Declaration

  Swift

      func latestBlockHeight(result: @escaping (Result<BlockHeight, Error>) -> Void)

- `downloadBlockRange(_:)`

  Downloads and stores the given block range. Blocking

  #### Declaration

  Swift

      func downloadBlockRange(_ range: CompactBlockRange) throws

- `rewind(to:)`

  Restore the download progress up to the given height.

  #### Declaration

  Swift

      func rewind(to height: BlockHeight) throws

- `lastDownloadedBlockHeight()`

  Returns the height of the latest compact block stored locally. BlockHeight.empty() if no blocks are stored yet Blocking

  #### Declaration

  Swift

      func lastDownloadedBlockHeight() throws -> BlockHeight

- `latestBlockHeight()`

  Returns the latest block height Blocking

  #### Declaration

  Swift

      func latestBlockHeight() throws -> BlockHeight

- `fetchTransaction(txId:)`

  Gets the transaction for the Id given

  Throws

  An error if the fetch failed

  #### Declaration

  Swift

      func fetchTransaction(txId: Data) throws -> TransactionEntity

  #### Parameters

  `txId` | Data representing the transaction Id

  #### Return Value

  a transaction entity with the requested transaction

- `fetchTransaction(txId:result:)`

  Gets the transaction for the Id given

  #### Declaration

  Swift

      func fetchTransaction(txId: Data, result: @escaping (Result<TransactionEntity, Error>) -> Void)

  #### Parameters

  `txId` | Data representing the transaction Id
  `result` | a handler for the result of the operation

- `fetchUnspentTransactionOutputs(tAddress:startHeight:)`

  Undocumented

  #### Declaration

  Swift

      func fetchUnspentTransactionOutputs(tAddress: String, startHeight: BlockHeight) throws -> [UnspentTransactionOutputEntity]

- `fetchUnspentTransactionOutputs(tAddress:startHeight:result:)`

  Undocumented

  #### Declaration

  Swift

      func fetchUnspentTransactionOutputs(tAddress: String, startHeight: BlockHeight, result: @escaping (Result<[UnspentTransactionOutputEntity], Error>) -> Void)

- `fetchUnspentTransactionOutputs(tAddresses:startHeight:)`

  Undocumented

  #### Declaration

  Swift

      func fetchUnspentTransactionOutputs(tAddresses: [String], startHeight: BlockHeight) throws -> [UnspentTransactionOutputEntity]

- `fetchUnspentTransactionOutputs(tAddresses:startHeight:result:)`

  Undocumented

  #### Declaration

  Swift

      func fetchUnspentTransactionOutputs(tAddresses: [String], startHeight: BlockHeight, result: @escaping (Result<[UnspentTransactionOutputEntity], Error>) -> Void)

- `closeConnection()`

  Undocumented

  #### Declaration

  Swift

      func closeConnection()

© 2022 Francisco Gindre and Jack Grigg. All rights reserved. (Last updated: 2022-04-07)

Generated by jazzy ♪♫ v0.14.2, a Realm project.