refactor: move definition of Peer and related types
refactor: move LocalPeer code into separate file