Create new NetworkEvent and push into the gossip graph



Hey everyone,

how can a peer push a new NetworkEvent into the gossip graph? Is there a specififc function for that. What I saw from the example at GitHub was that an enum “observation” is created, as a NetworkEvent. Is that necessary?



Hi there,

Yes, the function is Parsec::vote_for(), where you vote for a particular Observation.

The Observation enum includes variants for network events Add and Remove to indicate your vote to add or remove a given peer from the network.

I hope that answers your question? If not, please just ask further :slight_smile:



Thanks :slight_smile:

So, just to get you right. If Node A wants to create a new network event to be voted and gossiped about. She creates an instance of Observation and with Parsec::vote_for() this network event becomes a part of the gossip graph. The other peers then have the chance to vote for it.


No problem :slight_smile:

Yes, that’s correct. There’s one point I’d make though… and it may just be me misinterpreting your final sentence. The way we’re expecting to use Parsec, each peer would decide what network events to vote for independently of seeing each others’ Observations appearing in the shared graph.

So for example, if Node X shuts down, each connected peer would notice that the connection to X had dropped, and each would vote for Remove(X) at that point, rather than waiting to see anything in the graph before voting. If enough peers vote for that, it will eventually be output by Parsec::poll(), and the peers can then react appropriately (e.g. by updating their routing table, and stopping any reconnection attempts to X).

There’s nothing wrong with doing what I think you were suggesting, i.e. reacting to a single vote seen in the graph by casting further votes. It’s just that you’d need to be able to trust that single initial vote. If all Node A needs to do to get her peers to vote one out is cast a single vote herself, well that can easily be exploited by a malicious actor.


I recall that this was a thing I sort of misunderstood as well when I initially started reading up on Parsec, so thanks for emphasizing it @Fraser :slight_smile: