decred / vspd

A Voting Service Provider (VSP) for the Decred network.
ISC License
19 stars 21 forks source link

client: Send empty maps instead of nil. #491

Closed jholdstock closed 2 weeks ago

davecgh commented 2 weeks ago

What's the point of this change? In general, using empty reference objects instead of nil unless there is a very specific reason is not ideal because it causes additional allocations.

matheusd commented 2 weeks ago

Sending nil makes some VSPs fail this call, because the encoded JSON payload does not send the corresponding member (https://github.com/decred/dcrwallet/issues/2402).

Ideally, vspd should loosen the requirements for these members not to be nil, but we can't necessarily rely on VSPd operators to timely update their deployments, so this fixes the issue for callers in the mean time.

This isn't a hot path, but in any case the allocation issue (which to be fair is true) can be dealt with with a global empty map.