2193+ NodeId newId;
2194+ {
2195+ LOCK(cs_setTakenNodeIds);
2196+ do {
2197+ if (nLastNodeId == std::numeric_limits<NodeId>::max()) {
2198+ nLastNodeId = 0;
Not -1? (or =0 and having the ++ in an else?) Why should it fail to reconsider reusing 0?
The theoretical infinite loop is perhaps unfortunate, perhaps there should be an assert if size of the set is => max. (the reason for doing that would be more obvious if you imagine someone deciding to reduce the id to a s16 since its more than enough for current connections. :) )… or an exception.
Thanks, I’ll address both of those.
Edit: No need to address these if we’re not going to worry about wrapping.