feat(block-producer): borrow instead of cloning txs#544
feat(block-producer): borrow instead of cloning txs#544Mirko-von-Leipzig merged 2 commits intomirko-cleanup-mempoolfrom
Conversation
polydez
left a comment
There was a problem hiding this comment.
It seems that this PR introduces even more cloning than before, doesn't it? I found 3 cloning of transaction vector here.
Sort of. We have the following signature now: txs: impl IntoIterator<Item = Borrow<ProvenTransaction>> + Cloneand txs.iter().map(AuthenticatedTransaction::raw_proven_transaction),so the clones are clones of the iterator. This is a change from before where we cloned the inner transaction data: txs.iter().map(AuthenticatedTransaction::raw_proven_transaction).cloned().collect()I'm 95% confident this works how I expect it to. If there is a better/simpler way to express this borrow + reusable iterator bound then that would be perfect. |
|
@Mirko-von-Leipzig this makes sense, thank you! The confusing thing here is that we clone |
Agreed; and that is indeed much clearer. I was searching for a clone + iterator combo but missed the fact that you can specify the underlying iterator within |
This was previously added in #544 but was mistakenly dropped by a rebase.
This was previously added in #544 but was mistakenly dropped by a rebase.
This was previously added in #544 but was mistakenly dropped by a rebase.
Blocked by PR #543.
Removes the unnecessary deep cloning of transaction data by utilising
Borrow. TheTransactionBatch::newimplementation can probably be improved to reduce the amount of iteration occurring, but I'm delaying that until the dust settles on the mempool implementation.Closes #531