-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netsync: Rework inventory announcement handling.
This modifies the way inventory announcements are handled to improve efficiency and readability. Specifically, it switches to a more explicit approach that handles the specific recognized types (blocks and transactions) independently and now determines if they are needed with unique logic for each type as opposed to the more generic inventory-only based approach. Next, and probably the most important change overall is that recently confirmed transactions are now tracked by the server and the logic which determines if a transaction is needed now makes use of those tracked transaction as opposed to the previous rather expensive utxo-based query approach. The reasoning for this change is that the only time honest nodes notify others about transactions are when they view those transactions as unconfirmed and they consider themselves to be current. In practice this means the only duplicate announcements are for unconfirmed (which are filtered by the mempool) and recently confirmed transactions. In the case of malicious nodes, the transactions are rejected (either the transactions are actually invalid or they are old transactions that were valid in the past but will now fail due to trying to spend outputs they already spent). So, given the above discussion, there are 3 cases to handle: 1) Duplicate announcements for unconfirmed transactions 2) Duplicate announcements for txns that have already been rejected 3) Duplicate announcements for recently-confirmed transactions For the first case, the duplicate request is filtered because the mempool already knows the unconfirmed transaction. For the second case, rejected transactions are tracked separately and filtered. Thus, only the third case of recently confirmed transactions remains. Finally, the last block is now tracked by the hash instead of an index into the index which allows the relevant updates to take place after the main loop versus inside of it conditionally.
- Loading branch information
Showing
2 changed files
with
171 additions
and
219 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.