Distributed Algorithms For Peer-To-Peer Energy Trading