The stringReceived method of ShareExchanger starts with
if self.peer_id is None:
# Get peer ID.
else:
# Handle incoming share.
and it bugs me that we have to do this test every single time we
receive some data from another player!
I have an idea for streamlining this: we could initialize
incoming_data with a Deferred with a program counter of [0] or
something like that and then each player would send its player ID
using that program counter.
This will trigger the Deferred, which will then do what whatever the
first branch of the if-statement does today.
I hope we can gain some performance by having fewer conditional
statements on this critical path.
|