storj/satellite/console/consoleweb/consoleapi
paul cannon a16aecfa96 satellite/payments: specialized type for monetary amounts
Why: big.Float is not an ideal type for dealing with monetary amounts,
because no matter how high the precision, some non-integer decimal
values can not be represented exactly in base-2 floating point. Also,
storing gob-encoded big.Float values in the database makes it very hard
to use those values in meaningful queries, making it difficult to do
any sort of analysis on billing.

For better accuracy, then, we can just represent monetary values as
integers (in whatever base units are appropriate for the currency). For
example, STORJ tokens or Bitcoins can not be split into pieces smaller
than 10^-8, so we can store amounts of STORJ or BTC with precision
simply by moving the decimal point 8 digits to the right. For USD values
(assuming we don't want to deal with fractional cents), we can move the
decimal point 2 digits to the right.

To make it easier and less error-prone to deal with the math involved, I
introduce here a new type, monetary.Amount, instances of which have an
associated value _and_ a currency.

Change-Id: I03395d52f0e2473cf301361f6033722b54640265
2021-09-28 23:27:44 +00:00
..
analytics.go satellite/console/.../consoleapi: Standardize serveJSONError 2021-06-29 09:40:07 -04:00
apikeys_test.go satellite/console: Implement MFA backend 2021-07-26 16:37:05 +00:00
apikeys.go satellite/console/.../consoleapi: Standardize serveJSONError 2021-06-29 09:40:07 -04:00
auth_test.go satellite/console: Add CORS test 2021-08-31 15:48:52 +00:00
auth.go satellite/console: Allow basic headers in CORS preflight 2021-08-25 12:47:14 -04:00
buckets_test.go satellite/console: Implement MFA backend 2021-07-26 16:37:05 +00:00
buckets.go satellite/console/.../consoleapi: Standardize serveJSONError 2021-06-29 09:40:07 -04:00
common.go satellite/console: Forward friendly registration errors to client 2021-07-22 11:31:12 +00:00
payments.go satellite/payments: specialized type for monetary amounts 2021-09-28 23:27:44 +00:00
usagelimits_test.go satellite/console: Implement MFA backend 2021-07-26 16:37:05 +00:00
usagelimits.go satellite/console/.../consoleapi: Standardize serveJSONError 2021-06-29 09:40:07 -04:00