In a std::set, the value is also the key. In order to maintain its internal sorting, the key must be constant.
In other words, it's using set<const Peer *, PeerComparator>.
The error message says that in order to be const-correct, Peer::id() should be a const method (because symantically, it does not modify the state of the object).