refactor peers_check in consensus.py