polkadot icon indicating copy to clipboard operation
polkadot copied to clipboard

collator-protocol/validator_side: refactor collation fetching into a stream

Open ordian opened this issue 4 years ago • 2 comments

As of #4179, we're using a HashMap of Futures to track all collation fetching requests.

The problem is that it makes it hard to poll all collations in the main select! loop of the collator protocol. Doing it outside of select loop introduces a latency (up to 1s), because select! is blocking.

Consider using https://docs.rs/futures/0.3.17/futures/stream/struct.FuturesUnordered.html or something similar instead of HashMap of Futures.

ordian avatar Oct 30 '21 15:10 ordian

This should be pretty easy.

The main issue AFAIK is that we are using ctx when polling each future currently and then processing reputation changes. But we should just change it to a FuturesUnordered and use ctx to apply reputation changes to each one that concludes.

rphmeier avatar Oct 30 '21 15:10 rphmeier

The main issue AFAIK is that we are using ctx when polling each future currently and then processing reputation changes.

After #4179, reputation changes and ctx borrowing is separated from polling each future.

ordian avatar Oct 30 '21 16:10 ordian