Skip to content

Instantly share code, notes, and snippets.

@gubatron
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gubatron/acf1794fbccf342ea1b2 to your computer and use it in GitHub Desktop.
Save gubatron/acf1794fbccf342ea1b2 to your computer and use it in GitHub Desktop.
[OpenBazaar] Networking Core Refactor Notes

Networking/P2P code reorganization/refactor notes.

  • All Peer Connection related classes will go to a module called 'connection'
  • All Transport related classes will go to a module called 'transport'
  • Bye bye crypto2crypto.py and p2p.py, hello connection.py and transport.py
  • All static functions found on these classes that are not core to what they do but to utilitarian tasks that can be reused by other classes will be moved out of these classes and into utility modules (crypto_util.py), for example, cryptographic key handling functions don't belong on transport classes if they don't have any mention of self._properties in them, other classes can reuse, reducing the possibility of having a bug in multiple places.
  • kademlia.py was unused, there was only an exception class (TimeoutError) that was moved to the routingtable module.
  • major import cleanup. only importing the necessary, no unused imports.

MIGHT DO's

  • PeerConnection::send_raw: This method is invoked by send(data, callback), which means it's probably called every time we talk to a peer. It compresses the data to be sent, through a zmq socket it creates EVERY time it's called, this creation all done on a try catch block and a callback is defined to handle the immediate response, the callback closes the ZMQ stream that was created to register itself. My intuition tells me all of this might be wrong, specially if the zmq socket is equivalent to a tcp socket connected to the remote peer, we should make sure connections with our peers remain up, it's to expensive to reconnect for each and every message sent. the socket should be reused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment