Skip to content
  • Alin Dima's avatar
    Refactor availability-recovery strategies (#1457) · 6f00edbc
    Alin Dima authored
    Refactors availability-recovery strategies to allow for easily adding
    new hotpaths and failover mechanisms.
    
    The new interface allows for chaining multiple `RecoveryStrategy`-es
    together, to cleanly express the relationship between them and share
    state and code where neccessary/possible:
    
    This was done in order to aid in implementing new hotpaths like
    [systematic chunks
    recovery](https://github.com/paritytech/polkadot-sdk/issues/598) and
    [fetching from approval
    checkers](https://github.com/paritytech/polkadot-sdk/issues/575).
    
    Thanks to this design, intermediate state can be shared between the
    strategies. For example, if the systematic chunks recovery retrieved
    less than the needed amount of chunks, pass them over to the next
    FetchChunks strategy, which will only need to recover the remaining
    number of chunks.
    
    Draft example of how a systematic chunk recovery strategy would look:
    https://github.com/paritytech/polkadot-sdk/commit/667d870bdf1470525d66c13929d5eac7249dd995
    (notice how easy it was to add and reuse code)
    
    Note that this PR doesn't itself add any new strategy, it should fully
    preserve backwards compatiblity in terms of functionality. Follow-up PRs
    to add new strategies will come.
    6f00edbc