This is another small improvement taken from #10785.
Instead of manually converting from/to BE format in the CService serializer, provide a generic way in serialize.h to serialize BE data (only 16 bits for now).
435 | + } 436 | + 437 | + template<typename Stream> 438 | + void Serialize(Stream& s) const 439 | + { 440 | + if (sizeof(I) == 2) ser_writedata16be(s, m_val);
Why these checks if (sizeof(I) == 2)?
To more easily extend this later (if needed) to other sizes. I can get rid of them if that's confusing (they're always known at compile time).
At the moment is confusing/redundant because of the static assert above. Keep it simple?
Fixed.
Removed the if (sizeof(I) == 2) clauses, and added extra comments and checks.
utACK ece88fd.
Makes sense to also replace unsigned short port and unsigned short GetPort() with uint16_t?