slight refactor codes of p2pnet