FactomProject / factomd

Factom Daemon
https://www.factomprotocol.org/
Other
201 stars 92 forks source link

[Wax] Updates to P2P2 (Resend filter, minor fixes) #1012

Closed WhoSoup closed 4 years ago

WhoSoup commented 4 years ago

Summary from: https://github.com/WhoSoup/factom-p2p/pull/45

The most significant change would be the introduction of the Resend Filter. This was an idea originally proposed by Clay to be implemented in the old p2p system, though that implementation never worked. The gist is that it takes a certain amount of time for a message to be processed. During that period, nodes will receive the same message a multitude up of times from different nodes. The resend filter will store which nodes sent a specific message and when the time comes to rebroadcast that message, it will only send it to nodes that have not that specific message to us.

If the processing speed of messages is very fast, this filter has little to no benefit but during times of high traffic/tps, it can cut down on a substantial amount of wasted traffic.

Other changes:

  • Raising default channel size from 50 to 1000, allowing for higher theoretical burst traffic (discovered during local testing)
  • A race condition for starting the listener
  • Using built-in functions to read data for V11, where before it would fail for fragmented tcp parcels
WhoSoup commented 4 years ago

Addressed all of the comments except for the Close() one, which I don't think is necessary.