decred / politeia

ISC License
110 stars 75 forks source link

politeiavoter: Improve hoursprior UX. #1601

Closed lukebp closed 2 years ago

lukebp commented 2 years ago

This commit improves the --hoursprior UX by updating politeiavoter to the following behavior.

By default, the trickler will trickle in votes for the full duration of the vote minus 12h.

The --voteduration and the --hoursprior settings are not allowed to be used at the same time. An error is returned if they are attempted to be used together.

If a --voteduration is specified, the votes are trickled in over the specified duration.

If a --hoursprior is specified, the votes are trickled in over the full duration of the vote minus the specified hours prior.

If the calculated vote duration is less than 24h, the user MUST manually set the duration using the --voteduration flag.

Example 1

A vote has 6 days remaining. The user attempts to trickle in their votes over a 3h period using --voteduration=3h.

Previously, they would get the following error.

not enough time left to trickle votes: -9h0m0s < 12h0m0s, use
--hoursprior to modify this behavior

Using this commit, no error is returned and the votes are trickled in over the 3h period.

Example 2

A vote has 6 hours remaining. The user attempts to trickle in their votes without specifying a --voteduration.

Previously, they would get the following error.

not enough time left to trickle votes: -6h0m0s < 12h0m0s, use
--hoursprior to modify this behavior

With this commit, they now get the following error.

there is only 6h0m0s left in the vote; when the remaining time is this
low you must use --voteduration to manually set the duration that will
be used to trickle in your votes, example --voteduration=6h

Example 3

There is 28h left in a vote. The user attempts to trickle in their votes without specifying a --voteduration.

Previously, they would get the following error.

not enough time left to trickle votes: 4h0m0s < 12h0m0s, use
--hoursprior to modify this behavior

With this commit, the calculated vote duration is 16h (28h left in the vote minus the default 12h hours prior). 16h is less than the required 24h vote duration so they get the following error.

there is only 28h0m0s left in the vote; when the remaining time is this
low you must use --voteduration to manually set the duration that will
be used to trickle in your votes, example --voteduration=6h