[go: up one dir, main page]

Stdlib: implement pick_successful

Context

This MR introduces a handy pick_successful function, an extension to Lwt concurrency toolkit in Tezos stdlib. Unlike its elder sibling Lwt.pick which returns the first resolved promise from a list of promises, Lwt_utils.pick_successful returns the first successful promise from a list of promises

Example use case copied from #5673 (closed)

An Observer node should send a request for a missing page to each Committee Member. On the first successful response, all other requests should be cancelled. We can do this by returning a list of promises for each RPC request that was sent then, unlike Lwt.pick, we should choose the first successful promises not simply the first resolved. That is, if a promise is resolved but rejected, we should continue waiting on a pending promise until we get a successful promise or there are no more pending promises

Manually testing the MR

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Ryan Tan

Merge request reports

Loading