fix(p2p/sensor): improve transaction writing consistency#909
Merged
Conversation
- Change handleNewPooledTransactionHashes condition from || to && so transactions are requested when either --write-txs or --write-tx-events is enabled (previously required both) - Preserve earliest TimeFirstSeen for transactions by checking existing records before writing, matching block behavior - Skip writing transactions that already exist with earlier timestamp - Add --write-first-tx-event flag for write-first-event-only behavior - Add SensorFirstSeen field to DatastoreTransaction for sensor attribution
009338e to
87a5e26
Compare
…ation - Add fixed worker pool (default 100 workers) for transaction and transaction event writes using unbounded linked list queue - Check transaction cache before writing to deduplicate across peers - Add Close() method to Database interface for graceful shutdown - Add --write-workers flag to configure worker count - Keep semaphore pattern for block writes (lower volume) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove the worker pool implementation and revert to the original semaphore pattern for database writes. The cache-first transaction deduplication (added in previous commit) should significantly reduce write volume, making the simpler semaphore pattern sufficient. Changes: - Remove worker pool types, queue, and worker goroutines from datastore.go - Remove WriteWorkers from DatastoreOptions - Remove --write-workers flag from sensor command - Keep using runAsync() semaphore pattern for all database writes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Close() method was added for the worker pool implementation but is no longer needed after reverting to the semaphore pattern. With the semaphore pattern, in-flight goroutines complete on their own without needing explicit shutdown coordination. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extract common transaction processing logic into processTransactions() - Consolidates duplicate code from handleTransactions and handlePooledTransactions - Remove orphaned comment about Close() method - Remove duplicate WriteTransactions comment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
leovct
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Jira / Linear Tickets
Testing