net.corda.flows

## Class FetchDataFlow<T extends NamedByHash,W>

- FlowLogic
- - net.corda.flows.FetchDataFlow<T,W>

- Type Parameters:
    `T` - The ultimate type of the data being fetched.
    `W` - The wire type of the data being fetched, for when it isn't the same as the ultimate type.
  Direct Known Subclasses:
    FetchAttachmentsFlow, FetchTransactionsFlow

      public class FetchDataFlow<T extends NamedByHash,W>
      extends FlowLogic

  An abstract flow for fetching typed data from a remote peer.

  Given a set of hashes (IDs), either loads them from local disk or asks the remote peer to provide them.

  A malicious response in which the data provided by the remote peer does not hash to the requested hash results in `exception FetchDataFlow.DownloadedVsRequestedDataMismatch` being thrown. If the remote peer doesn't have an entry, it results in a `exception FetchDataFlow.HashNotFound` exception being thrown.

  By default this class does not insert data into any local database, if you want to do that after missing items were fetched then override maybeWriteToDisk. You must override `FetchDataFlow.load`. If the wire type is not the same as the ultimate type, you must also override convert.

  See Also:
    `exception FetchDataFlow.DownloadedVsRequestedDataMismatch`, `exception FetchDataFlow.HashNotFound`, `FetchDataFlow.load`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FetchDataFlow.Request`
    `static class` | `FetchDataFlow.Result<T extends NamedByHash>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FetchDataFlow(java.util.Set<? extends net.corda.core.crypto.SecureHash> requests, Party otherSide)` An abstract flow for fetching typed data from a remote peer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `FetchDataFlow.Result<T>` | `call()` This is where you fill out your business logic. The returned object will usually be ignored, but can be helpful if this flow is meant to be used as a subflow.
    `T` | `convert(W wire)`
    `Party` | `getOtherSide()`
    `java.util.Set<net.corda.core.crypto.SecureHash>` | `getRequests()`
    `T` | `load(SecureHash txid)`
    `void` | `maybeWriteToDisk(java.util.List<? extends T> downloaded)`

    - ### Methods inherited from class net.corda.core.flows.FlowLogic

      `call, getCounterpartyMarker, getLogger, getProgressTracker, getRunId, getServiceHub, getStateMachine, receive, send, sendAndReceive, setStateMachine, subFlow, subFlow, track, waitForLedgerCommit`

- - ### Constructor Detail

    - #### FetchDataFlow

          public FetchDataFlow(java.util.Set<? extends net.corda.core.crypto.SecureHash> requests,
                               Party otherSide)

      An abstract flow for fetching typed data from a remote peer.

      Given a set of hashes (IDs), either loads them from local disk or asks the remote peer to provide them.

      A malicious response in which the data provided by the remote peer does not hash to the requested hash results in `exception FetchDataFlow.DownloadedVsRequestedDataMismatch` being thrown. If the remote peer doesn't have an entry, it results in a `exception FetchDataFlow.HashNotFound` exception being thrown.

      By default this class does not insert data into any local database, if you want to do that after missing items were fetched then override maybeWriteToDisk. You must override `FetchDataFlow.load`. If the wire type is not the same as the ultimate type, you must also override convert.

      See Also:
        `exception FetchDataFlow.DownloadedVsRequestedDataMismatch`, `exception FetchDataFlow.HashNotFound`, `FetchDataFlow.load`

  - ### Method Detail

    - #### call

          public FetchDataFlow.Result<T> call()

      This is where you fill out your business logic. The returned object will usually be ignored, but can be helpful if this flow is meant to be used as a subflow.

    - #### maybeWriteToDisk

          public void maybeWriteToDisk(java.util.List<? extends T> downloaded)

    - #### load

          public T load(SecureHash txid)

    - #### convert

          public T convert(W wire)

    - #### getRequests

          public java.util.Set<net.corda.core.crypto.SecureHash> getRequests()

    - #### getOtherSide

          public Party getOtherSide()