refactor: Broadcast tx insert to p2p #670
Conversation
… into controlc/p2p_tx
… into controlc/p2p_tx
* cleaned up feature flags * fmt * fix leak: * fmt again
|
I actually would prefer to hold off on this since the txpool is particularly performance sensitive and the double iteration over tx's. It might also be useful later to separate |
We should generally try to avoid code duplication, as it makes future refactors more difficult - there might not be any immediate errors or tests that fail if the shared behavior changes in one and not the other. If we really want to optimize out an extra for-loop, there are other ways to do that without maintaining duplicate code. |
|
You could argue that the path is still O(2N) = O(N). Before, we did N iterations of 2 operations; now, we do 2N iterations of 1 operation each. (This is, of course, a simplification of the actual case). I would bet that the performance hit would be fairly negligible in this context. I think the increased maintainability and simplicity outweigh the potential performance benefit. |
insert_with_broadcastmethodinsert_with_broadcastwith sequentialinsertfollowed by broadcast for each inserted txThis approach reduces some code complexity at the cost of second iteration over the transactions. See the discussion in the parent PR here #590 (comment).