dcrd/internal/rpcserver
Dave Collins 59e1d24513
blockchain: Make zero val threshold tuple invalid.
This makes the zero value for a threshold state tuple act as the invalid
state and choice instead of using magic sentinel values.

In practice, callers should be checking the error of any methods before
using any other returned values, however, the code typically tries to
adopt a defense in depth model where it makes sure unusable/invalid
values are also returned in error cases to help make it obvious when a
caller incorrectly uses the returned value without checking the error.

It accomplishes this by reording the threshold states so that the
invalid state is 0 and converting the choice field to a pointer to the
relevant choice as opposed to a choice index.  That way the zero value
for the overall type is the invalid state and nil the choice, exactly as
expected.

In addition to being more ergonomic and inline with typical Go code, it
has a few additional benefits:

* Makes the type harder to misuse
* Simplifies identification of a specific resulting choice for votes
  that have multiple affirmative choices since the choice can be checked
  by its ID instead of a tightly coupled array index
* Provides an easy method to distinguish between a vote that failed due
  to a majority vote and one that failed due to expiring before a
  majority result was achieved
2023-03-13 21:43:40 -05:00
..
testdata rpcserver: Add handleSearchRawTransactions tests. 2020-08-29 22:03:04 -05:00
doc.go rpcserver: Move to internal. 2020-07-24 23:29:59 -05:00
interface.go multi: Remove unused next state depl ver param. 2023-02-27 02:24:56 -06:00
log.go rpcserver: Add logging to internal package. 2019-10-24 21:37:27 -05:00
README.md rpcserver: Move to internal. 2020-07-24 23:29:59 -05:00
rpcserver_test.go rpcserver: Add limited methods exist test. 2022-12-05 13:12:02 -06:00
rpcserver.go rpcserver: Decouple RPC agenda info status strings. 2023-03-04 21:32:07 -06:00
rpcserverhandlers_test.go blockchain: Make zero val threshold tuple invalid. 2023-03-13 21:43:40 -05:00
rpcserverhelp_test.go rpcserver: add handleVersion, handleHelp rpc tests. 2021-01-16 18:52:34 -06:00
rpcserverhelp.go rpcserver: Remove unused method refs from limited. 2022-12-05 13:11:59 -06:00
rpcwebsocket.go multi: Use atomic types in unexported modules. 2023-02-13 10:02:56 -06:00

rpcserver

Build Status ISC License Doc

Overview

Package rpcserver includes all RPC server interfaces, types, and pieces of code pertaining to implementing the RPC server.

License

Package rpcserver is licensed under the copyfree ISC License.