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.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR