fix(gadget-sdk)!: prevent duplicate and self-referential messages #458
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.
This pull request includes several changes to improve the network and gossip handling in the
sdk
module. The updates mainly focus on enhancing the peer connection logic, adding new fields to structures, and refining the message handling process to avoid redundant operations and ensure efficient memory usage.Network and Gossip Handling Improvements:
Peer Connection Logic:
JoinSet
withFuturesOrdered
to manage peer connection tasks more efficiently inblueprint-manager/src/sdk/setup.rs
.wait_for_peers
to handle peer connections asynchronously.Structure Enhancements:
my_id
field toNetworkServiceWithoutSwarm
andNetworkService
structures to track the peer's own ID insdk/src/network/gossip.rs
. [1] [2]recent_messages
field usingLruCache
to store recently received message hashes and prevent processing duplicates inGossipHandle
. [1] [2]Message Handling:
sdk/src/network/handlers/gossip.rs
andsdk/src/network/handlers/p2p.rs
. [1] [2]recent_messages
inGossipHandle
. [1] [2]Test Improvements:
sdk/src/network/mod.rs
. [1] [2] [3] [4]Dependency Updates:
lru-mem
dependency to manage the LRU cache for recent messages inCargo.toml
andsdk/Cargo.toml
. [1] [2]