-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: improve performance of HandleTransactionGet, by requesting all transactions from InvMsg at once #25
Conversation
…transactions from InvMsg at once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand how the change speeds up the processing. As I see, you simply moved for loop from one function to another.
It doesn't call the function for each hash but passes those hashes together as a slice. But the work in the next function is the same - you go through all the hashes/txs and do the same operation. So the only change here is the place of the for loop.
Am I missing something here ? 🤔
Not really. With this change we can limit database round trips as we request for few transactions in one call. |
Where is the decrease of DB calls in here? What do you mean? I still don't see it |
This is the current implementation of With the new version, the client (e.g., So, this change is not a performance improvement per se, but it provides the possibility for improvement by the library client. |
I see, I was just looking for optimisation in p2p code. That makes sense now. Please consider backwards compatibility. I think it's kinda hard fork with this change. |
What has been done
Method
HandleTransactionGet(msg *wire.InvVect, peer PeerI) ([]byte, error)
was changed to
HandleTransactionsGet(msg []*wire.InvVect, peer PeerI) ([][]byte, error)
.This change allows for more efficient transaction getting, because it bundles all tx requests from the InvVect message, instead of asking for transactions one-by-one.
Why I modified this method, instead of leaving it as it was and adding another one?
Potential downsides