dcrd/internal/rpcserver
Dave Collins bf57746c3b
standalone: Introduce CalcTSpendWindow.
This existing code for calculating treasury spend window values, namely
CalculateTSpendWindowStart and CalculateTSpendWindowEnd, has a couple of
footguns:

- The starting value calculation returns totally invalid values without
  an error when provided with a expiry that is prior to the first voting
  window
- Expiry values that are invalid for the start calc are valid for the
  end calc even though they should not be

As a result, the code for handling the error paths in the rpc server and
mining code produces error messages that don't make sense in some cases
because they blindly print the start value without checking the error.

To remove the aforementioned footguns and also address the incorrect
error messages, the following overview of changes are made:

- Replaces the CalculateTSpendWindowStart and CalculateTSpendWindowEnd
  functions with a single combined CalcTSpendWindow function that
  properly checks for expiries before the first possible voting interval
- Modifies the returned errors to match the new reality
- Shortens the prefix to Calc to match the rest of the function names in
  the package
- Updates the incorrect error handling paths to avoid reporting the
  values that are not guaranteed to be meaningful and modifies the error
  messages to be more consistent
- Adds a comprehensive set of tests for the new function

Note that in addition to addressing the aforementioned issues, this
approach has at least a couple of other benefits:

- It is more efficient to have a single function with a single bounds
  check
- Almost all callers outside of the tests need both the start and end
  value anyway, so it allows more compact code

Finally, this updates all callers in the repository accordingly.
2020-09-29 11:32:13 -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 rpcserver: Add support for gettreasuryspendvotes 2020-09-24 11:46:21 -05: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: Move to internal. 2020-07-24 23:29:59 -05:00
rpcserver.go standalone: Introduce CalcTSpendWindow. 2020-09-29 11:32:13 -05:00
rpcserverhandlers_test.go rpcserver: Add searchrawtransactions count limit. 2020-09-26 12:11:15 -05:00
rpcserverhelp_test.go rpcserver: Move to internal. 2020-07-24 23:29:59 -05:00
rpcserverhelp.go rpcserver: Add support for gettreasuryspendvotes 2020-09-24 11:46:21 -05:00
rpcwebsocket.go multi: Add decentralized treasury support. 2020-09-21 12:15:31 -05:00
treasury_test.go rpcserver: Verify tbase values in treasury rpctest 2020-09-24 12:19:12 -05: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.