-
Notifications
You must be signed in to change notification settings - Fork 30
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
send txs out #31
send txs out #31
Conversation
@@ -94,10 +111,40 @@ func (p *TxProcessor) Start() { | |||
// start listening for transactions coming in through the channel | |||
p.log.Info("Waiting for transactions...") | |||
for txIn := range p.txC { | |||
go p.sendTxToReceivers(txIn) |
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.
that place receives duplicates, it should probably be sent at https://github.com/flashbots/mempool-dumpster/blob/main/collector/tx_processor.go#L174
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.
this place in code is after a bunch of operations including writing to a file and request to a node
also duplicates count over all sources but we send only for allowed sources so this can lead to a big loss of txs
I think its better for receiver to do filtering then.
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.
You are mistaken, the transactions are written to a file later, after deduplicating, inside the processTx function.
Your comment about loss of tx because filtering makes sense though. Would be good to add a comment about why this line of code is in this place.
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.
here where writing to a file https://github.com/flashbots/mempool-dumpster/blob/main/collector/tx_processor.go#L123 happens that I refer to
and its before deduplicating
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.
added comment 62915f4
if err != nil { | ||
return err | ||
} | ||
defer res.Body.Close() |
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.
To reuse the HTTP connection, you'll need to read the full body before closing: https://blog.cubieserver.de/2022/http-connection-reuse-in-go-clients/#:~:text=Client%20will%20only%20reuse%20connections,MaxConnsPerHost%20).
// ensure that we close the request so the httpClient can reuse the connection
io.Copy(io.Discard, res.Body)
res.Body.Close()
Co-authored-by: Chris Hager <[email protected]>
📝 Summary
Allows sending out collected txs.
--tx-receivers-allowed-sources
is a list of tx sources to resend--tx-receivers
urls where to send txs (as a octet-stream POST request)⛱ Motivation and Context
📚 References
✅ I have run these commands
make lint
make test
go mod tidy